Network Mocking Interview Questions for Playwright Testing
34 Network Mocking questions with answers for playwright testing roles — 6 easy, 21 medium, 7 hard.
About Network Mocking
Covers intercepting traffic with page.route and context.route, fulfilling, modifying and aborting requests, HAR replay, waiting for requests and responses, WebSocket mocking and offline testing. Interviewers ask how you test error states, slow APIs and third-party services, and how you balance mocked tests against real end-to-end coverage.
What is the difference between route.fulfill, route.continue and route.abort?
Show answer
How do you block images and fonts to speed up tests?
Show answer
Why mock the network in UI tests at all?
Show answer
Describe a time you argued against mocking every API in the suite.
Show answer
What is a HAR file?
Show answer
How do you mock third-party APIs in UI tests?
Show answer
How do you wait for a network response in Playwright?
Show answer
How do you mock network requests?
Show answer
How do you change part of a real API response?
Show answer
What is the difference between page.route and context.route?
Show answer
How do you mock network traffic using a HAR file?
Show answer
Why should you start waitForResponse before the action that triggers it?
Show answer
Your mocked route never fires. What do you check?
Show answer
How do you test how the UI handles a 500 error from the orders API?
Show answer
How do you simulate a slow API to test a loading spinner?
Show answer
How do you listen to all network requests on a page?
Show answer
How do you assert that a request was sent with the correct payload?
Show answer
How do you test offline behaviour?
Show answer
How does URL matching work in page.route?
Show answer
A third-party analytics script makes tests slow and flaky. What do you do?
Show answer
How do you mock one GraphQL query when all calls go to /graphql?
Show answer
How do you add or change request headers for only some requests?
Show answer
The app polls a status endpoint every few seconds. How do you test the change from Pending to Done?
Show answer
Tell me about a time mocking helped you test a hard edge case.
Show answer
How do you return a fake JSON response that depends on the request body?
Show answer
How do you test that the app retries a request that failed the first time?
Show answer
When should you avoid mocking, and how do you balance mocked and real tests?
Show answer
Mocked responses drift from the real API and tests pass while production breaks. How do you prevent this?
Show answer
How do you mock WebSocket traffic in Playwright?
Show answer
A feature is controlled by a flag served from a config API. How do you test both states?
Show answer
How do you mock a paginated endpoint that returns different data per page?
Show answer
How can service workers interfere with network mocking?
Show answer
A fixture mocks every /api call, but one test needs a different response for /api/cart. How do you override it?
Show answer
Frequently asked questions
How important is Network Mocking in Playwright Testing interviews?
Covers intercepting traffic with page.route and context.route, fulfilling, modifying and aborting requests, HAR replay, waiting for requests and responses, WebSocket mocking and offline testing. Interviewers ask how you test error states, slow APIs and third-party services, and how you balance mocked tests against real end-to-end coverage.
How should I use the Network Mocking sheet?
Go top to bottom — easy to hard. Answer before opening each answer, tick what you solved and save misses to Last-Minute Revision.