Playwright · Middle · Question 17 of 75
How do you simulate a server error for one endpoint?
- 1
route.fulfill({ status: 500 })in apage.routehandler - 2Stop the backend server before that test starts running
- 3Set
offline: truefor the whole browser context
Show the answer
Correct answer: route.fulfill({ status: 500 }) in a page.route handler
Explanation
Mocking a 500 lets you check the error state of the UI deterministically, without breaking a shared backend.