Cypress says script error thrown in cross origin script - do not know why

See original GitHub issue

Hello!

Everything works ok. 0 errors in Chrome or in tests console. But I get this error. And all pipeline is broken.

If there is a error, why it is hidden from me?

Uncaught Error: Script error.

Cypress detected that an uncaught error was thrown from a cross origin script.

We cannot provide you the stack trace, line number, or file where this error occurred.

Check your Developer Tools Console for the actual error - it should be printed there.

It's possible to enable debugging these scripts by adding the 'crossorigin' attribute and setting a CORS header.

https://on.cypress.io/cross-origin-script-error

This error originated from your application code, not from Cypress.

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the 'uncaught:exception' event.

https://on.cypress.io/uncaught-exception-from-application

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

28reactions
jennifer-shehanecommented, Nov 28, 2018

@hiren0007 I’m not totally sure why this is displaying as a ‘cross origin error’. It looks like there is an error in Harpers own code trying to console.log() an undefined variable when the window loads. Perhaps I’m wrong about it not being from a cross origin script though 🤔

screen shot 2018-11-28 at 12 53 40 pm

If this is not your website and you cannot fix the error, I suggest adding a check to ignore uncaught errors in Cypress like below:

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

it('fails to visit website 1', function () {
  cy.visit('https://harper-morpho-luna.myshopify.com')
})
4reactions
felipenmouracommented, Jul 24, 2019

Hello. Interestingly, this workaround (bypassing uncaught errors) work in the open ui, but still fail in terminal/cli! And when I simply return false for that listener, it locks hanging the terminal, never ending the tests.

Any reason for that?!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Messages | Cypress Documentation
Cypress detected that an uncaught error was thrown from a cross-origin script. Browser Errors; The browser process running your tests just exited unexpectedly ......
Read more >
Cypress throws "cross origin error happened on page load ...
This error means that your application navigated to a superdomain that Cypress was not bound to. Initially when you cy.visit() , Cypress ...
Read more >
Cypress says script error thrown in cross origin script - do not know ...
If this is not your website and you cannot fix the error, I suggest adding a check to ignore uncaught errors in Cypress...
Read more >
cypress-io/cypress - Gitter
Error : Uncaught Error: Script error. Cypress detected that an uncaught error was thrown from a cross origin script. We cannot provide you...
Read more >
Fixing Cypress cross-origin errors - Reflect.run
This is due to how Cypress is architected. Other testing tools like Selenium and Playwright operate outside of the browser runtime, and ...
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