Playwright · Middle · Question 16 of 75

What does this route do?

await page.route("**/api/products", (route) =>
  route.fulfill({ json: [{ id: 1, name: "Mock" }] })
);
Show the answer

Correct answer: Returns fake JSON instead of calling the real API

Explanation

route.fulfill answers the request from the test. It's useful for edge cases like empty lists or errors that are hard to get from a real backend.

Further reading

Problem with a question

Playwright · Middle · question 16

Test yourself

Take the Playwright · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz