-
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
Using assertion outside the test context leads to nasty crash without good message #345
Comments
Also, it seems this error is linked to https://docs.cypress.io/docs/errors#section-no-tests-found-in-your-file while it is more appropriate to link to https://docs.cypress.io/docs/errors#section-we-found-an-error-preparing-your-test-file |
This is simply an uncaught global exception (which we are not correctly catching) from the spec file. We'll catch errors obviously from within a test but not outside of it. There's a difference between parse errors and runtime errors. Runtime errors simply lead Cypress to not find any valid tests (since the code bails early) - whereas parse / bundle errors are caught prior to sending down the spec files and can be displayed. The solution here is simple - catch global uncaught spec errors so we can notify the user there's something wrong with their code. We already catch global uncaught errors from the application under test, so that same code can be repurposed to catch spec errors. |
agree this is the best long term solution. Double points because it solves problem a new user might have (which are higher priority in my mind) |
The code for this is done, but this has yet to be released. We'll update the issue and reference the changelog when it's released. |
If I use "expect" outside a
describe
block, Cypress 0.18.1 fails to parse the file and shows "no tests found message". It is very unclear to the user why the tests do not start.It could also related to the "cy.log" command I have added by using #342
I could not reliably recreate the crash in the self-contained example, but this is the principle
Trying to run this breaks Cypress with message "No tests found in your file:" and the following error stack and object arguments (this shows that this is the "expect" assertion crashing)
The text was updated successfully, but these errors were encountered: