Uncaught Exception not failing a test
See original GitHub issue- Operating System: Mac
- Cypress Version: 2.0.4
- Browser Version: Chrome Version 64.0.3282.186
Is this a Feature or Bug?
Bug… I think?
Current behavior:
Added a setTimeout(() => { throw new Error('Whoops!') }, 200)
in my application code and ran a test that took a couple of seconds to run and it successfully completed.
Desired behavior:
I was under the impression that any uncaught exception will cause any test that’s running to fail. If I was wrong is there any way to ensure that the test fails? I tried adding the following code but the debugger never fired:
cy.on('uncaught:exception', (err, runnable) => {
debugger
})
cy.on('window:alert', (err, runnable) => {
debugger
})
How to reproduce:
- Add
setTimeout(() => { throw new Error('Whoops!') }, 200)
to any application code - Run a test that take a couple of seconds to ensure that error gets thrown
- See the test succeed instead of fail.
Additional Info (images, stack traces, etc)
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Cypress on uncaught exception is not working - Stack Overflow
Uncaught exceptions are only for application errors. Failures within the test code are caught by Cypress but are then reported as a test...
Read more >Failing Tests on Uncaught Exceptions, automatically?
I'm using CppUTest for a while now, and recently I recognized that tests doesn't fail if my code under test throws an exception....
Read more >Error Messages | Cypress Documentation
Test File Errors No tests found This message means that Cypress was unable to find tests in the specified file. You'll likely get...
Read more >Testing Error Handling in node.js | by Lars Trieloff
That the function under test is not exiting normally, but throwing an error or exception. · That the thrown exception matches the API...
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
@brian-mann I have something similar, there is JS error happening when I do
cy.go('back')
, and cypress somehow ignores it, and continues as normal.Is there anything else I can provide to help resolve the issue?
Thank you.
@swathisham
https://github.com/cypress-io/cypress/issues/2487#issuecomment-461547038
I’m tracking this issue instead ☝️