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.

Uncaught SyntaxError: Invalid or unexpected token happening out of nowhere in CI/CD

See original GitHub issue

Current behavior:

All of a sudden, out of nowhere, all of my Cypress tests are failing when run in CircleCI, with the following:

Uncaught SyntaxError: Invalid or unexpected token

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

Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'Coupons'

This is happening across multiple Angular projects. I have no idea where to begin to even pinpoint the issue - when I run Cypress via cypress open, all of my tests run fine.

I’m suspicious it’s one of the npm packages I updated in between deploys, so here’s the package.json DIFF:

image

Desired behavior:

The builds should run properly both in headless mode in CircleCI and locally. If that doesn’t work, at least give me more info so I can chase down the issue.

Steps to reproduce: (app code and test code)

  • I check in my code
  • CircleCI picks up the change and runs it
  • I get the aforementioned error in the Cypress dashboard

This just started today.

Versions

Cypress 3.4.1, Chrome 65

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
mitschmidtcommented, Sep 5, 2019

Encountered the same issue and solved it by using this approach: https://github.com/cypress-io/cypress/issues/4042#issuecomment-487562075

5reactions
andrewryan1906commented, Aug 1, 2019

" But, there’s no evidence that this is an issue with Cypress,"

Guys; if Cypress works for weeks at a time, and then all of a sudden starts spitting out this error, ONLY in CircleCI, and with no other information that can help me understand what the problem is or begin to troubleshoot, then it is BY DEFINITION an issue with Cypress. At the very least, I think it reasonable for the tool to provide helpful information that would allow me to start to locate the issue.

And - the fact that I cannot reproduce it locally is highly suspect.

Perhaps you’ve encountered this before? Or some hints or where it could be? I have about 200 packages… removing them 1 at a time to get to the bottom of this is not an ideal solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Uncaught SyntaxError: Invalid or unexpected token" occurs ...
The error it's not happening every time start running by cypress, and if I manually input the URL into the browser to visit...
Read more >
SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
Troubleshooting CI/CD - GitLab Docs
An early source of problems can be incorrect syntax. The pipeline shows a yaml invalid badge and does not start running if any...
Read more >
Have a JavaScript Unexpected Token Error? Check Your Syntax
The Technical Rundown · All JavaScript error objects descend from the Error object or an inherited object therein. · The SyntaxError object is ......
Read more >
Troubleshooting Cloud Functions - Google Cloud
Others have to do with incorrect configuration. User with Viewer role cannot deploy a function. A user who has been assigned the Project...
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