Mock network route
mock_routeIntercept browser requests matching a URL pattern to return canned responses, errors, or delays, enabling UI tests for API failures and timeouts without contacting the real server.
Instructions
Intercept browser requests matching a URL glob and answer them with a canned response, an error, or a delay, without contacting the real server. Tests UI behavior for API errors, payment declines, timeouts and outages. Only the browser sees the mock; no backend is contacted. Mocks persist until clear_mocks.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | No | Raw body text (ignored when json is given) | |
| json | No | JSON body (sets content-type application/json) | |
| abort | No | Fail the request with this network error instead of responding | |
| times | No | Only mock the first N matching requests | |
| method | No | Only mock this HTTP method | |
| status | No | HTTP status to return | |
| delayMs | No | Delay before responding | |
| headers | No | Extra response headers | |
| urlPattern | Yes | Glob matched against the full URL, e.g. "**/api/checkout*" or "https://api.example.com/v1/**" | |
| contentType | No | Content-Type for a raw body (default text/plain) |