Cypress · Junior · Question 56 of 75

What happens to a window.alert() in a Cypress test?

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.

Further reading

Problem with a question

Cypress · Junior · question 56

Test yourself

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

Take this quiz