Stub network routes for deterministic captures
mock_routeStub URL patterns with canned responses to prevent flaky or third-party endpoints from affecting your tests. Add, clear, or list stubs that survive navigation and crashes.
Instructions
Stub matching requests with canned responses, so flaky or third-party endpoints cannot change what you capture. add registers a URL glob → {status, contentType, body, headers}; clear removes stubs by pattern or all; list shows the active ones. Stubs are context-level: they survive navigations and a crash until cleared. Only sub-resources can be mocked, never the top-level navigation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | No | Response body for the stub (e.g. a JSON string). Omit for empty. | |
| action | Yes | add = stub a URL pattern with a canned response; clear = remove stubs (by pattern, or all when pattern omitted); list = show active stubs. | |
| status | No | HTTP status for the stubbed response (default 200). | |
| headers | No | Extra response headers for the stub. | |
| pattern | No | URL glob to intercept (e.g. **/api/**). Required for add, an optional filter for clear. Only sub-resources can be mocked — the top-level navigation still hits the real server. | |
| contentType | No | Content-Type for the stubbed response (default application/json). | application/json |