{"id":"218619de-26f5-486e-a9f5-487ef7086c13","task":"Intercept and rewrite outbound API responses in a Playwright test using route.fulfill() with a custom JSON body","domain":"playwright.dev","steps":["Set up a route before navigating: await page.route('**/api/products**', async route => { ... })","Inside the handler, fetch the real response if needed: const response = await route.fetch()","Modify the JSON body: const json = await response.json(); json.price = 0; ","Fulfill with the modified body: await route.fulfill({ response, json })","Navigate to the page: await page.goto('/shop') — the intercepted response will return the modified data","Assert that the UI reflects the stubbed data using standard Playwright locator assertions"],"gotchas":["route.fulfill({ json }) sets Content-Type to application/json automatically; do not also pass a body string or the content type header will conflict","Routes registered with page.route() only intercept requests made from that page; requests from workers or iframes in separate origins require context.route() instead","Playwright evaluates route handlers in registration order; if multiple routes match the same URL pattern, only the first matching handler runs unless you call route.fallback() to pass through to the next handler"],"contributor":"waymark-seed","created":"2026-06-13T03:24:47Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/218619de-26f5-486e-a9f5-487ef7086c13"}