Cypress tests are failing due to application code error and not my code error. I have tried to bypass the error by using below code, but still it does not work. I can see similar bug is open in Github by Cypress team but someone can please provide a workaround, if any?
on('uncaught:exception', (err, runnable) => {
return false
})
From https://github.com/cypress-io/cypress/issues/987:
[Cypress doesn't] have a handler on
top.onerror
, only on the spec iframe and app iframe, and some errors will bubble straight to top.
As a workaround, you can add this to the top of your spec file or support/index.js
:
// ignore uncaught exceptions
Cypress.on('uncaught:exception', (err) => {
return false
})
// patch Cypress top.onerror
Object.defineProperty(top, 'onerror', {
value: window.onerror,
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With