Cypress · Middle · Question 63 of 77

How can a Cypress test fail if the app logs console errors?

Show the answer

Correct answer: Spy on console.error in onBeforeLoad and assert

Explanation

cy.visit(url, { onBeforeLoad(win) { cy.spy(win.console, 'error').as('err') } }) then assert on @err.

Further reading

Problem with a question

Cypress · Middle · question 63

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