Cypress.on('uncaught:exception') receives CypressError instead of thrown error
See original GitHub issueCurrent 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
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
Cypress.on('uncaught:exception') No Longer Preventing Tests ...
Cypress.on ('uncaught:exception') receives CypressError instead of ... error was being thrown in the Cypress test runner itself, rather than ...
Read more >Cypress Uncaught Assertion Error despite cy ... - Stack Overflow
Uncaught Error: Script error. Cypress detected that an uncaught error was thrown from a cross origin script. We cannot provide you the stack...
Read more >Error Messages | Cypress Documentation
Cypress detected that an uncaught error was thrown from a cross-origin script. Browser Errors; The browser process running your tests just exited unexpectedly ......
Read more >How to handle Errors in Cypress | BrowserStack
Error handling is essential to avoid false failed tests. Learn different ways of Cypress Error and Exception Handling techniques with this ...
Read more >Handle Service Unavailable and Uncaught Exception in ...
In this video, I have explained how to solve handle service unavailable error and Uncaught Exception in Cypress.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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: