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

Advice for encountering uncaught exceptions during test runs #8

Open
alexfinnarn opened this issue Dec 1, 2022 · 1 comment
Open

Comments

@alexfinnarn
Copy link
Collaborator

During a test run, if Cypress encounters an unhandled exception, it fails the test run. Sometimes the exception relates to custom code, but sometimes it relates to third-party code and it might only happen intermittently.

Cypress provides some advice for handling these scenarios: https://docs.cypress.io/api/events/catalog-of-events#To-turn-off-all-uncaught-exception-handling

Cypress.on('uncaught:exception', (err, runnable) => {
  // returning false here prevents Cypress from
  // failing the test
  return false
})

You can add that to a describe() or it() block's scope or try to handle them more globally. What should the guidance be for encountering uncaught exceptions?

@dmundra
Copy link
Collaborator

dmundra commented Dec 1, 2022

I would say avoid it if possible unless the case of the third-party code and then comment the reason for the use. Similar to wait(), don't use but if you do comment the reason why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants