Cypress · Senior · Question 44 of 76

How do you test that an API error shows a friendly message without a real failing backend?

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.

Further reading

Problem with a question

Cypress · Senior · question 44

Test yourself

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

Take this quiz