outofcoffee / imposter

Scriptable, multipurpose mock server. Run standalone mock servers, or embed mocks within your tests.

Home Page:https://imposter.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docs: improve description of steps

outofcoffee opened this issue · comments

Supported step types:

Type Purpose
remote Make an HTTP(S) call to an endpoint
script Execute a script file

Remote example:

plugin: rest

resources:
  # example setting query param, headers and content
  - path: /example1
    method: GET
    steps:
      - type: remote
        url: http://localhost:8081
        method: POST
        queryParams:
          petId: "${context.request.queryParams.petId}"
        headers:
          X-Test-Header: "test"
        content: '{ "type": "cat" }'
    response:
      content: "Request sent"

  # example with capture
  - path: /example2
    method: GET
    steps:
      - type: remote
        url: http://localhost:8081
        method: GET
        capture:
          petName:
            store: request
            expression: "${remote.response.body}"
          statusCode:
            store: request
            expression: "${remote.response.statusCode}"
    response:
      content: "${stores.request.petName}"
      template: true

Script example:

plugin: rest

resources:
  - path: /example
    method: GET
    steps:
      - type: script
        file: test.js
    response:
      content: "${stores.request.foo}"
      template: true

WIP on docs/steps