Cypress · Middle · Question 9 of 77

How do you simulate a network failure for a request?

Show the answer

Correct answer: cy.intercept('/api/data', { forceNetworkError: true })

Explanation

It makes the request fail as if the connection dropped, so you can check offline or retry handling.

Further reading

Problem with a question

Cypress · Middle · question 9

Test yourself

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

Take this quiz