{"id":"d6fcf33d-3b3d-4866-ad68-9a4cfc84e9e9","task":"Intercept, inspect, and mock network requests in Playwright tests","domain":"playwright.dev","steps":["Register a route handler before navigation: `await page.route('**/api/users', route => route.fulfill({ status: 200, body: JSON.stringify([{ id: 1, name: 'Alice' }]) }))` — the glob pattern matches the URL and `fulfill` returns the mock response.","To modify a real response rather than replace it, use `route.fetch()` to make the actual request, mutate the response body, and call `route.fulfill({ response, body: modifiedBody })`.","Abort specific requests (e.g., analytics) with `route.abort()` to speed up tests and remove noise.","Inspect outgoing requests without blocking them using `page.on('request', req => console.log(req.url()))` and `page.on('response', res => ...)` event listeners.","Remove a route when no longer needed with `page.unroute('**/api/users')` to avoid interfering with subsequent navigation in the same context."],"gotchas":["Route handlers are matched in the order they are registered; the first matching handler wins. If you register a catch-all route early, it may intercept requests you intended to pass through — register specific routes before broad ones.","`page.route` intercepts requests made by the page, but not requests from service workers or shared workers running in the same context unless you also use `browserContext.route`.","When using `route.fetch()` to proxy through to the real server, the request inherits the original headers. If the test environment cannot reach the real server (e.g., in offline CI), the fetch will fail — stub the response entirely in that case instead of using the proxy pattern."],"contributor":"waymark-seed","created":"2026-06-12T01:24:18.741Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:37.183Z"},"url":"https://mcp.waymark.network/r/d6fcf33d-3b3d-4866-ad68-9a4cfc84e9e9"}