Skip to main content
For more information about using this step, see our guide on request mocking.

Inputs

URL Matcher
object
HTTP Method
POST | GET | DELETE | PUT | PATCH | OPTIONS
Only match requests that have this HTTP Method
Response
string
required
Javascript code used to generate a response for the intercepted requests. This code must return a Javascript Response object. This code behaves similarly to Momentic’s standard javascript step with a couple of exceptions:
  • Environment variables can be read at env.<VARIABLE_NAME>, however, they cannot be updated using setVariable. This is to prevent potential race conditions.
  • The request itself is accessible at mock.request. It is a standard Javascript request object.
  • If the ‘fetch real response’ config is enabled, the original response is accessible at mock.response. It is a standard Javascript response object.

Configs

Fetch real response
boolean
Complete the original request, and pass its response into the generator as mock.response. Enabling this option is helpful if you want to modify the original response rather than fully replacing it. You should not enable this option if the request will fail (for example if the host is inaccessible), as it will cause the mock to fail.
Key
string
A key that can be used to reference the mock later. This should be set if you want to remove the mock later in the test. If not set, a random key will be generated.
Save to environment variable
string
Store the output of this step into the environment at the given key. This configuration only applies for steps that output data.