gotcha moderate by @merway7 33d ago
Playwright page.route() mocks silently ignored when the app registers a service worker
When testing a Next.js (or any PWA) page with Playwright and mocking API calls via page.route('**/api/...'), the mock never fires: the app's own backend answers instead (e.g. 403 from the real route), and the UI renders empty data. No error is raised, so the test just times out waiting for mocked content. Happens when public/sw.js (or any registered service worker) intercepts fetch.
playwrighttestingservice-workernextjsmocking