-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught Exception not failing a test #1385
Comments
Cypress will absolutely catch uncaught exceptions and fail the current test. There are lots of tests around this behavior. What I imagine is happening here is some kind of edge case either that we didn't consider or that this isn't a real uncaught exception. We will not catch errors if:
What we'd need you to do is reduce down your example to whatever is the simplest to recreate. For instance I can see you are using HMR. If HMR is configured to work through an You can look at our own tests as reference. To test uncaught exception handling - just throw an error directly in an Since uncaught exceptions can handle in a ton of different ways, we wrote tests that express them in all kinds of circumstances. For instance they could happen:
All of this behavior is tested in the driver code and in the e2e tests that run Cypress in a 'pure' form the same as you run your projects.
|
Closing because we've not heard back and nobody has provided a reproducible case. |
@brian-mann I have something similar, there is JS error happening when I do Is there anything else I can provide to help resolve the issue? Thank you. |
@alexindigo Hey, giving us a reproducible issue is the best way to help resolve an issue. |
Reproducible & super simplified version right here: #2487 (comment) Someone please give it a look, because this issue just keeps happening in our app that we test in Cypress and it's causing me so much pain :( |
Hey @jennifer-shehane, I have a reproducible, very simple test case here: describe("Visiting IFTTT", function() {
it("should ignore the occuring JavaScript error", function() {
cy.viewport(1024, 880);
cy.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
console.log("Catched exception");
return false;
});
cy.visit("https://ifttt.com/");
cy.get('a.sign-in').click();
});
}); The result is (currently, it might change if IFTTT works on their site, of course) nearly 100% that there will be a JavaScript error that lets the test fail, although there's a Here is a video of the failure: I'm using Cypress 3.4.0 on Windows, installed via npm install and run via Hope this helps to pinpoint the issue. |
Hi, @brian-mann Just to be clear, when you say:
it means that it will not work (or be flaky) if the Example: // This action will trigger an Exception
cy.get('#myButton').click();
// Catch Exception AFTER the actual action
cy.on('uncaught:exception', (err, runnable) => {
return false;
}); This won't work ? |
any update on this issue? |
I'm tracking this issue instead ☝️ |
I am getting assertion error. But test passed even though it shows assertion error |
Please follow this issue or open a new issue with a completely reproducible example #2487 |
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:
How to reproduce:
setTimeout(() => { throw new Error('Whoops!') }, 200)
to any application codeAdditional Info (images, stack traces, etc)
The text was updated successfully, but these errors were encountered: