cypress: Cypress.on('uncaught:exception') receives CypressError instead of thrown error
Current behavior:
This might be a regression with Cypress 5.0.
I have a global catch for ResizeObserver loop limit exceeded in my support/index.js file.
const resizeObserverLoopErrRe = /^ResizeObserver loop limit exceeded/
Cypress.on('uncaught:exception', err => {
if (resizeObserverLoopErrRe.test(err.message)) {
return false
}
})
As of version 5, I started noticing that when this error occurs, the handler will receive a CypressError instance, instead of the original error containing the above message. This therefore makes the tests fail, and returns the usual info message about this error:
The following error originated from your application code, not from Cypress.
> ResizeObserver loop limit exceeded
When Cypress detects uncaught errors originating from your application it will automatically fail the current test.
This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.
https://on.cypress.io/uncaught-exception-from-application
Desired behavior:
The handler should receive the actual globally thrown error, as it previously did.
Test code to reproduce
https://github.com/vicrep/cypress-test-tiny/pull/1/files
Versions
Cypress: 5.0.0 Browser: Both on Electron and Chrome (didn’t test others) OS: Reproed on macOS and Linux
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (2 by maintainers)
Commits related to this issue
- Ignore ResizeObserver warning, unclear why this occurs, happened in https://github.com/GMOD/jbrowse-components/commit/93cc783ccbac but is sometimes recommended to ignore, xref https://github.com/cypre... — committed to GMOD/jbrowse-components by cmdcolin 2 years ago
- Ignore ResizeObserver warning, unclear why this occurs, happened in https://github.com/GMOD/jbrowse-components/commit/93cc783ccbac but is sometimes recommended to ignore, xref https://github.com/cypre... — committed to GMOD/jbrowse-components by cmdcolin 2 years ago
- Ignore ResizeObserver warning, unclear why this occurs, happened in https://github.com/GMOD/jbrowse-components/commit/93cc783ccbac but is sometimes recommended to ignore, xref https://github.com/cypre... — committed to GMOD/jbrowse-components by cmdcolin 2 years ago
- Ignore ResizeObserver warning, unclear why this occurs, happened in https://github.com/GMOD/jbrowse-components/commit/93cc783ccbac but is sometimes recommended to ignore, xref https://github.com/cypre... — committed to GMOD/jbrowse-components by cmdcolin 2 years ago
- Ignore ResizeObserver warning, unclear why this occurs, happened in https://github.com/GMOD/jbrowse-components/commit/93cc783ccbac but is sometimes recommended to ignore, xref https://github.com/cypre... — committed to GMOD/jbrowse-components by cmdcolin 2 years ago
- Ignore ResizeObserver warning, unclear why this occurs, happened in https://github.com/GMOD/jbrowse-components/commit/93cc783ccbac but is sometimes recommended to ignore, xref https://github.com/cypre... — committed to GMOD/jbrowse-components by cmdcolin 2 years ago
- Ignore `ResizeObserver` errors in Cypress tests This commit addresses false negative failures in Cypress due to a known Chrome issue. The included change prevents Cypress tests from failing because ... — committed to undergroundwires/privacy.sexy by undergroundwires 3 months ago
- Ignore `ResizeObserver` errors in Cypress tests This commit addresses false negative failures in Cypress due to a known Chrome issue. The included change prevents Cypress tests from failing because ... — committed to undergroundwires/privacy.sexy by undergroundwires 3 months ago
@jennifer-shehane Please note that the regular expression you posted actually matches “any text starting with a character that is not one of
() ORcdeilmoprstvxz” (all characters present in(ResizeObserver loop limit exceeded)), which is patently wrong and causes a lot of other errors to be possibly swallowed.A simple way to safely-enough ignore just this specific error is:
We changed how the errors are constructed in 4.6.0+, you’ll need to upgrade your Regex to match the newly constructed error:
I am having the same issue after upgrading to
10.0.2as well @willoliveira-air @jennifer-shehane . Below is my configuration:While the
cy.logandconsole.logstatements are working as expected, it seems that Cypress can no longer ignore exceptions.Using
cy.viewportin multiple tests in the same file caused this issue for me; moving it to abeforehook sidestepped it.@alineborak Your error is different than the
ResizeObserverone, so you would need to change the regex to look forScript error. Or better, don’t include the NewRelic tracker in your test env.I also created a fresh bug ticket to shed some light on the issue, as this bug pertains to a newer version of Cypress: https://github.com/cypress-io/cypress/issues/22129
I started to see the same issue after upgrading to version 10.2. Even using the workaround from @jennifer-shehane jennifer-shehane
Any ideas? Thanks