Skip to content
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

Some asynchronously thrown spec errors do not fail test #8802

Closed
flotwig opened this issue Oct 9, 2020 · 5 comments
Closed

Some asynchronously thrown spec errors do not fail test #8802

flotwig opened this issue Oct 9, 2020 · 5 comments
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory type: bug

Comments

@flotwig
Copy link
Contributor

flotwig commented Oct 9, 2020

Current behavior

Uncaught rejections thrown in tests that use done will not fail the test when no cy chain is active:

# bad
it "quux8 fails", (done) ->
Cypress.Promise.resolve()
.then ->
foo.bar()
return

Similar behavior exists for other unhandled rejections:

# bad, doesn't log to console, unlike Promiser unhandled rejections
it "quux7d fails", (done) ->
window.top.setImmediate ->
foo.bar()

Potentially related: some asynchronous test failures are incorrectly attributed to the AUT, not the spec window.

Desired behavior

Correctly attribute unhandled rejections and exceptions to the spec or the AUT, do not miss handling any errors.

Test code to reproduce

See #8221

@flotwig flotwig added type: bug pkg/driver This is due to an issue in the packages/driver directory labels Oct 9, 2020
@flotwig
Copy link
Contributor Author

flotwig commented Oct 9, 2020

This affects cy.route2 req/res callbacks pretty hard - failing assertions in those callbacks will display in the command log, but will not cause the test to be failed.

@Andarist
Copy link
Contributor

Wouldnt this be just a matter of binding correctly unhandledrejection listener in those places:

// set onerror global handler
contentWindow.onerror = callbacks.onError

specWindow.onerror = function () {

top.onerror = onTopError

If that's the answer then I could work on fixing this.

@github-actions
Copy link
Contributor

Internal Jira issue: TR-670

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 1, 2021

The code for this is done in cypress-io/cypress#14826, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 5, 2021

Released in 7.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory type: bug
Projects
None yet
Development

No branches or pull requests

4 participants