Cypress · Junior · Question 56 of 75
What happens to a window.alert() in a Cypress test?
- 1Cypress auto-accepts it; listen via
window:alert - 2The test fails immediately with an uncaught error
- 3The test pauses until someone clicks OK
Show the answer
Correct answer: Cypress auto-accepts it; listen via window:alert
Explanation
Use cy.on('window:alert', (text) => ...) to assert the message. For confirm, return false from window:confirm to cancel.