Cypress · Senior · Question 44 of 76
How do you test that an API error shows a friendly message without a real failing backend?
- 1Change the backend code to return errors in staging
- 2Shut down the backend before that test runs
- 3Stub the endpoint with an error status and assert the UI
Show the answer
Correct answer: Stub the endpoint with an error status and assert the UI
Explanation
cy.intercept(..., { statusCode: 500 }) tests error states deterministically without affecting others.