cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Huge amount of uncaught exceptions: Cannot set properties of undefined (setting 'status')

Open juanpallares opened this issue 4 years ago • 4 comments
trafficstars

Current behavior

When doing cy.visit() I get a huge amount of uncaught exceptions

image

I'm catching the exceptions so the cypress tests are not affected but I don't want this exceptions to happen

Cypress.on('uncaught:exception', (err) => {
  // returning false here prevents Cypress from
  // failing the test
  if (err.message && err.message.includes('Cannot set propert')) {
    return false;
  }
  return true;
});

Desired behavior

No exceptions since it's a just a simple visit to a public webpage

Test code to reproduce

cy.visit('https://www.vistaprint.ca/clothing-bags/t-shirts/fruit-of-the-loom-r-ink-printed-5-ounce-heavy-cotton-hd-tm-t-shirt', { timeout: 15000 })

Cypress Version

8.7.0

Other

No response

juanpallares avatar Oct 29 '21 10:10 juanpallares

The exceptions are coming from the code of the site you are visiting. Cypress can't do anything about this. Or does it only happen when the site is run in Cypress?

Narretz avatar Oct 30 '21 08:10 Narretz

We fixed the issue with this workaround, adding this in each test suite:

beforeEach(() => {
          cy.log('Blocking NewRelic scripts');
          //Will block
          //  https://js-agent.newrelic.com/nr-spa-1208.js
          cy.intercept(/\.*newrelic.*$/, (req) => {
            console.log('NEW RELIC INTERCEPTED');
            req.reply("console.log('Fake New Relic script loaded');");
          });
          cy.visitPageWithSize(url, size);
        });

juanpallares avatar Nov 03 '21 07:11 juanpallares

My god @juanpallares, this happened to be my issue exactly. I have a project that loads new relic as well. Good catch!

tsirilson avatar Jan 06 '22 16:01 tsirilson

I have the same issue, however the exception is thrown from the inline NewRelic script that in turn loads a script matching the regex in @juanpallares answer.

What's disconcerting is that running through the identical test flow manually, in the exact browser/version Cypress is using, results in zero exceptions. The exceptions are only thrown when exercising the application via Cypress

timdoherty avatar Aug 10 '22 00:08 timdoherty

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

cypress-app-bot avatar May 15 '23 16:05 cypress-app-bot

This issue has been closed due to inactivity.

cypress-app-bot avatar May 31 '23 20:05 cypress-app-bot