cypress: `Cypress.on('uncaught:exception')` No Longer Preventing Tests From Failing after Upgrade to `10.0.2`
Current behavior
Cypress is not ignoring the following error:

My cypress/support/e2e.js file is configured so that Cypress should return false on an uncaught:exception in order to prevent the test from failing. This is no longer working as expected after upgrading to the latest version, 10.0.2, as the test is failing.
Desired behavior
In this situation, Cypress should pass the it statement while ignoring the error and throwing any specified logging.
Test code to reproduce
Cypress.on('uncaught:exception', (err) => {
// returning false here prevents Cypress from
// failing the test
console.log('Cypress detected uncaught exception: ', err);
return false;
});
Cypress Version
10.0.2
Other
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 14
- Comments: 24 (13 by maintainers)
@danfooks since your error comes from the application itself, the problem is likely a bit different. I noticed you are using
cy.origin, in which case you likely need a separateuncaught:exceptionhandler incy.originto catch that error and not throw it in your main test, something like:@ZachJW34 For myself, it is occurring consistently for every test run. I did check the ResizeObserver bug ticket, which seems to be the root cause of my issue. Also, If I am correct I should not have to check for a regex expression to be present in the error as @willoliveira-air is doing, as I want to catch all errors, rather than just this specific one. If it helps you to reproduce, below is the code that is triggering the issue in my test. This occurs consistently (every test run) for both Chrome and Electron. The code uses an href from a button and
cy.originto navigate to an external page using thebaseUrland thepathof the external page:Thanks for picking this up Zach, and let me know if I can provide any further information!
@willoliveira-air I am going to continue our conversation on issue #22113 as I think you and @mlberkow are having the same, if not a very similar issue, i.e. a resize observer failure that is being generated from the test itself, not the application.
One thing I did notice that I found interesting is that it looks like the
ResizeObserverfailures in from @willoliveria-air 's case come from the test itself, which will not work withuncaught:exception, similar to #22113. What happens if you try thefailhandler out of curiosity? Something like