question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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)

2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
alexindigocommented, Aug 25, 2018

@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.

Uncaught Exception

Is there anything else I can provide to help resolve the issue?

Thank you.

1reaction
andezzatcommented, Dec 28, 2019
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found