-
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
Cypress failing after uncaught:exception thrown from 3rd party, even thought 'uncaught:exception' handler is listening. #987
Comments
Okay so there are two issues here:
|
@brian-mann Sorry, the uncaught exception is being thrown by my application. However Cypress should not stop because of that, I update my issue. |
I know why the error is being thrown on my application, kind of. I know the line it is breaking on and why. Not exactly sure on why the code isn't running though. If you want I can post that information also? |
Can you prove that is happening? Put a debugger in the Alternatively just bind to |
Both Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
debugger
return false
})
Cypress.on('fail', (err) => {
debugger
}) Did not trigger the debugger |
did you have dev tools open before the tests ran? |
I'm 100% sure the Where are you putting them? |
I added Cypress.on('uncaught:exception', (err, runnable) => {
return false;
}); to support/index.js and tests fail anyways because of app's runtime exceptions. Cypress.on('fail', (err, runnable) => {return false}); then tests don't fail but they also don't run. |
@asos-arun @Gennadiii Could you both also follow these directions by adding the |
@jennifer-shehane Thanks a lot for your quick response . I have tried with below code and its not working. Cypress.on('uncaught:exception', (err, runnable) => {
debugger
return false
})
Cypress.on('fail', (err) => {
debugger
}) Let me know if i am missing anything? |
Here is a much more in depth explanation on why the uncaught:exception may not be being hit: #1385 (comment) We will need a reproducible example to truly investigate the issue further. |
In my case I get error in Cypress: Cannot read property 'payload' of undefined. But weird thing is that I don't see this error in console. It is caught by Cypress and I can see it in console only if I click it in Cypress panel. Cypress.on('uncaught:exception', (err, runnable) => {
console.log(`11111111111111111111111 ${err}`);
debugger;
return false;
}); No log, no debugger. This code works as expected: Cypress.on('fail', (err) => {
debugger;
}); But doesn't do what I need to do. |
@Gennadiii We are a small team and have invested a lot of time into this issue. We believe this is a problem with Cypress, but we are unable to reproduce or recreate. We will have to have a reproducible repo in order to get this fixed. We will keep this issue open as reference until someone provides how this is happening. Since you expressed hesitation to provide a reproducible repo because you're working on a commericial project, please note that we do offer premium support for users to prioritize bug fixes, do screensharing, and code reviews. If you're interested in this kind of premium support, we can look directly at how/why this is happening. Please let us know by emailing [email protected]. |
@brian-mann Thanks for your suggestion we will consider the support option. Meanwhile I have some more info that might help on this one. There are some http queries that site makes. |
Have you tried setting up a |
Hi, I have a similar problem. I request my application with cy.visit('/'). The application starts fetching data, but most of the times this will result in a 401. (even on the login page). This is expected behaviour, but catching the error with Cypress and returning false still results in the tests not continuing. |
I'm dealing with the same issue i think. i can't get it to do a cy.log when it throws an XHR request error. you can see my issue (different issue?) here: #1710 |
Same here. Getting following error in my application: Every test is failing due to it even though I have Can you please fix this issue after 1 year of waiting? |
This comment has been minimized.
This comment has been minimized.
My issue was I did not put cy.on('uncaught:exception', (err) => {
expect(err.message).to.include('Ignoring error for now');
return false;
}); inside of my context('Page Availability', () => {
beforeEach(() => {
cy.on('uncaught:exception', (err) => {
expect(err.message).to.include('Ignoring error for now');
return false;
});
});
}); |
As @bmarti44 stated - please ensure you have your listener set up properly to catch uncaught exceptions within Cypress. Unfortunately we'll have to close this issue if no reproducible example is provided. Can anyone provide a way to reproduce this? |
@mgrybyk Maybe I've missed it. Could you point me to the exact application code and test code that I can run locally on my machine to produce this error? |
@jennifer-shehane Just figured out why some people always has it and others have never faced this issue. Cypress can't catch exceptions thrown by 3rd party javascript that is loaded from different origin. Not sure about reproducible example, it might take some time on my side |
@jennifer-shehane got it.
Cypress.on('uncaught:exception', (err, runnable) => {
return false;
}); won't work here. Error: Script error. (:0)
at global.onerror (http://www.sickchirpse.com/__cypress/runner/cypress_runner.js:23142:10) |
Thanks so much @mgrybyk for providing a reproducible example. Failing example it('Does not catch script error', () => {
Cypress.on('uncaught:exception', (err, runnable) => {
throw err
})
cy.visit('http://www.sickchirpse.com/10-of-the-worst-websites-ever/')
}) |
@automationJatinder and |
No. @maximkoshelenko Please share your code where you are facing error. I think I have solution for the same. |
@automationJatinder Thanks. Here you go |
@maximkoshelenko awesome, I was able to reproduce with this. We're not catching errors thrown by wrapped |
@bkucera Super. Hope fix will be published soon :) my POC project are burning because of that issue. |
The code for this is done in cypress-io/cypress#5249, but has yet to be released. |
Released in |
@jennifer-shehane I have been following this thread and I am still experiencing this issue in version 4.0.0. I noticed that it is pointing out issues in node_modules in node_modules which doesn't make sense. We successfully used our custom npm package on our api tests. |
@azaeng04 if you are experiencing this issue, please open a new issue with fully reproducible example we can run |
@bahmutov I can show an image of what I am seeing and I can mention the node_module where the error is being thrown |
Not sure why it would be pointing to a node_module in the node_modules? And the fs-extra package to be exact. |
Not sure what we can determine from just images. A reproducible example would nice IF this is a bug in Cypress and not an artifact of bundling specs or your own application
…Sent from my iPhone
On Mar 3, 2020, at 14:39, Azariah ***@***.***> wrote:
@bahmutov I can show an image of what I am seeing and I can mention the node_module where the error is being thrown
Not sure why it would be pointing to a node_module in the node_modules? And the fs-extra package to be exact.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@bahmutov it seems to be pointing out errors in the
This package is in a custom package of ours and Cypress seems to throw an error and fail because of a variable(s) that is not a function as per the above. Help on this would be much appreciated @jennifer-shehane @bahmutov @brian-mann |
@azaeng04 this issue has been closed, so any comments here are usually non-productive. Second, your issue seems to be unrelated to the original - it seems you are trying to run Node file commands from Cypress tests which is impossible (Cypress tests run in the browser). If you want to use |
This issue will be closed to further comment as the exact issue here was resolved and tested in 3.6.0. If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix. Also, check out our community chat, it can be helpful for debugging or answering questions on how to use Cypress. |
Current behavior:
On the initial spec run, with a new browser, the exception is thrown from my application
If I rerun the test, without closing the browser, the test passes and the error is not thrown.
I don't expect you to solve my applications errors. However, this does not occur in a local chrome window, might be useful.
The real issue is when the uncaught exception is thrown by my application it stops Cypress from executing the test and any other tests. However, the page still loads. (See the video attached)
If I am correct, Cypress should not stop with application errors with
in commands.js, which it is
Desired behavior:
Cypress does not stop executing when the application throws an exception.
Additional Info (images, stack traces, etc)
https://youtu.be/m0O_P0alpyc
The text was updated successfully, but these errors were encountered: