Intercept network requests and mock their response
Response
object. This
code behaves similarly to Momentic’s standard javascript step with a couple of
exceptions:env.<VARIABLE_NAME>
, however, they cannot be updated using setVariable
. This is to prevent potential race conditions.mock.request
. It contains the following fields:
url
: string
method
: GET | POST | PUT | PATCH | DELETE | OPTIONS
headers
: Record<string, string>
json
: unknown | undefined
(set if the content-type is application/json
)text
: string | undefined
(set if the content-type is not application/json
)mock.response
. It contains the following fields:
status
: number
headers
: Record<string, string>
json
: unknown | undefined
(set if the content-type is application/json
)text
: string | undefined
(set if the content-type is not application/json
)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.