cypress: Getting Error: Script error. (:0) - How to resolve?
Current behavior:
Cypress test run fails on Chrome in before() with a cryptic error message:
Error: Script error. (:0)
Because this error occurred during a ‘before all’ hook we are skipping the remaining tests in the current suite: ‘Pets - Feed item’
Please see this screenshot:

Desired behavior:
A detailed error message should appear and should include clear instructions on how to resolve the problem.
Steps to reproduce: (app code and test code)
I’ve not been able to reproduce based on cypress-test-tiny repo so I’ve created a private repo containing a full test suite. I’ve sent emailed instructions on how to access it to support@cypress.io.
To reproduce using said repo, please:
- Clone to Ubuntu.
- Run
npx cypress open. - Run this spec file:
sanity/pets/feed_item.spec.js
Versions
Cypress v3.4.0 Ubuntu 16.04 LTS Chrome 75
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (8 by maintainers)
The best workaround to see the source of error right now on the Guardian website for example is:
cypress.jsonThen rerun the test with DevTools open again and it should see better errors
assets.guim.co.ukso add it to the blacklists incypress.jsoncypress.jsonand finally the site loads
Having the same issue but i managed to find a workaround, in my case at least. Try setting
"chromeWebSecurity": falseincypress.json. Before disabling web security i was gettingError: Script error. (:0), after disabling it cypress was logging the correct error.@urig Cypress’s current implementation is to fail on uncaught exceptions, as we don’t see this as an optimal workflow for an application. In these cases, we offer the option to opt out of failing on these uncaught exceptions with a listener. https://on.cypress.io/catalog-of-events#Uncaught-Exceptions
Unfortunately, this listener doesn’t trigger when uncaught errors are thrown from 3rd party code, which has caused some frustration for users. We do intend to fix this - https://github.com/cypress-io/cypress/issues/987
I’ll bring up this issue with our engineering team and see what we can do. Currently, these issues are not in our current sprint to be fixed.
Hi @jennifer-shehane and thanks.
I recognize that an error in the application is at the root of the issue and, using the
chromeWebSecurity: falseworkaround, I think we’ve been able to find out where this error is coming from. Several people on our side are working on fixing the error (it likely comes from a rather complex Google Tag Manager system we have embedded)At the same time, the other side of the issue is that Cypress should not break the spec file like this. From our end users’ perspective the JS error is transparent and does not negatively affect UX. So having Cypress crash about half of a sanity E2E tests in this scenario does not make for a good testing experience.
In short - Is there a time line for changing this behavior in Cypress?
Thanks, urig
@sebike88 thanks for the workaround. It sort of worked. I think the difference is that now I can see the underlying error coming from app code.