question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Cypress.on('uncaught:exception')` No Longer Preventing Tests From Failing after Upgrade to `10.0.2`

See original GitHub issue

Current behavior

Cypress is not ignoring the following error: uncaughtexception

My cypress/support/e2e.js file is configured so that Cypress should return false on an uncaught:exception in order to prevent the test from failing. This is no longer working as expected after upgrading to the latest version, 10.0.2, as the test is failing.

Desired behavior

In this situation, Cypress should pass the it statement while ignoring the error and throwing any specified logging.

Test code to reproduce

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

Cypress Version

10.0.2

Other

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
AtofStrykercommented, Jun 10, 2022

@willoliveira-air I am going to continue our conversation on issue #22113 as I think you and @mlberkow are having the same, if not a very similar issue, i.e. a resize observer failure that is being generated from the test itself, not the application.

1reaction
AtofStrykercommented, Jun 8, 2022

@danfooks since your error comes from the application itself, the problem is likely a bit different. I noticed you are using cy.origin, in which case you likely need a separate uncaught:exception handler in cy.origin to catch that error and not throw it in your main test, something like:

const baseUrl = 'https://www.sampleUrl.com/';

function testLoginPageLink(selector, pageDetails) {
  cy.get(selector)
    .should('have.attr', 'href').and('include', `${baseUrl}${pageDetails.path}`)
    .then((href) => {
      cy.origin(baseUrl,
        { args: { hrefPath: href.substring(26), title: pageDetails.title }}, ({ hrefPath, title }) => {
          Cypress.on('uncaught:exception', () => false)
          cy.visit(hrefPath);
          cy.contains(title);
        });
    });
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Migration Guide | Cypress Documentation
Migrating to Cypress 12.0 This guide details the changes and how to change your code to migrate to Cypress version 12.0.
Read more >
node.js - Migrating cypress test from old version to latest ...
I have had many packages fail with mysterious errors when running them on the latest (Node 18). I am sure this will not...
Read more >
Upgrade Cypress to Version 10 - Medium
Even though version 10 is a major version upgrade for cypress, turns out it's very simple and ... Click the “E2E Testing” to...
Read more >
cypress: Versions - Openbase
Upgraded the Chromium browser version used during cypress run and when ... Hooks will no longer rerun on unrelated tests in some situations...
Read more >
rouch/Cypress: Fast, easy and reliable testing for ... - NotABug
Cypress - Fast, easy and reliable testing for anything that runs in a browser.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found