Cypress test for a site that uses onbeforeunload and a confirmation prompt
Read window.onbeforeunload and Cypress
Original Cypress issue #2118
npm install
npm run dev
- click on the spec, play with the cypress/integration tests and the application code.
In DevTools console you can execute the following code, but I did not see it cleanly remove all event listeners
getEventListeners(window).beforeunload
.forEach(({ type, listener, useCapture }) => {
console.log('removing', type, listener, useCapture)
window.removeEventListener(type, listener, useCapture)
})