Answer a request from a rule instead of the server
qa_mockOverride matching fetch/XHR responses in a tab with custom status, body, delay, or network failure to test error paths, empty payloads, and retry behavior.
Instructions
Override what the app RECEIVES from the network — the thing DevTools calls a local override, driven from here. Set a rule and the page's next matching fetch/XHR is answered by it: your status, your body, optionally after a delay, or as an outright network failure. This is how you test the paths a server will not produce on demand: an empty list, a 500, a 403 that should log the user out, a 30-second response that should show a spinner, a malformed payload, a field the API does not return yet. op:'list' is free and READS the rules in force; set / remove / toggle / clear change what the app sees and need the Agent control consent, because an app fed an invented 200 can persist it. MATCHING: url is a substring of the full URL, or /regex/flags when you wrap it in slashes; method defaults to any. First matching enabled rule wins. times spends the rule after N answers (leave it out for unlimited) — that is how you make the FIRST call fail and the retry succeed. LIFETIME: a rule belongs to ONE TAB, survives reloads of it, and is gone when it closes. It is not in force in any other tab. WHAT IT DOES NOT CATCH, so you do not debug a rule that was never consulted: only the page's own fetch/XHR in the top frame. Not the HTML document itself, not images/scripts/stylesheets, not WebSocket or EventSource, not sendBeacon, not requests made inside an iframe or from the page's own service worker. Mocked responses are logged as (mocked) in the session, the HAR and the report — a value you invented is never presented as the server's. Remember to clear rules when you are done; a forgotten mock is the most expensive thing here.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "qa_mock"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Rule id, for remove / toggle / editing an existing rule | |
| op | No | Default 'set' | |
| url | No | Substring of the request URL, or /regex/flags | |
| body | No | Response body, verbatim. JSON-looking bodies get a JSON content-type unless you set one | |
| fail | No | Fail at the network level (fetch rejects, XHR fires error) instead of answering | |
| note | No | Why this rule exists — shown to the human in the panel | |
| tabId | No | Target tab (from qa_tabs); omit for the active tab | |
| times | No | Apply at most N times, then let the real request through | |
| method | No | GET / POST / … — omit to match any method | |
| status | No | Status to answer with (default 200) | |
| delayMs | No | Hold the answer back this long — for spinners and timeouts (max 60000) | |
| enabled | No | For op:'toggle' | |
| headers | No | Response headers |