Skip to main content

Documentation Index

Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

Requires exactly one URL matcher. responseGenerator is a JavaScript function body evaluated for every match. It receives the captured mock.request (and mock.response when fetchOriginalResponse is set) and returns the response body.

Parameters

ParameterTypeRequiredDescription
substringstringNoMatch URLs that contain this substring.
globstringNoMatch URLs against a glob pattern.
regexstringNoMatch URLs against a regular expression.
domainstringNoMatch all URLs under the given domain.
methodstringNoRestrict mocking to a specific HTTP method.
responseGeneratorstringYesJavaScript expression that returns the response body.
fetchOriginalResponsebooleanNoMake the real request first and pass the response to the generator.
keystringNoStable key for removeRouteMock.
saveAsstringNoName of the variable to write this step’s return value to.
retriesnumberNoNumber of times to retry the step on failure before failing the test.
skippedbooleanNoSkip this step at execution time.
commentstringNoFree-form annotation kept with the step.

Examples

- mock:
    substring: /todos
    method: get
    responseGenerator: |-
      return new Response(
        JSON.stringify([
          { id: 1, title: "mocked" },
        ]),
        { status: 200, headers: { "content-type": "application/json" } }
      )
    fetchOriginalResponse: false
    key: TODOS_MOCK
- mock:
    domain: setcookie.net
    fetchOriginalResponse: true
    responseGenerator: |-
      mock.response.headers.set("Set-Cookie", "sessionId=a3fWa")
      return mock.response