Cypress · Middle · Question 63 of 77
How can a Cypress test fail if the app logs console errors?
- 1Spy on
console.errorinonBeforeLoadand assert - 2Console messages can't be observed in Cypress
- 3Cypress fails the test on console errors automatically
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.