Cypress: Cypress Uncaught SyntaxError: Unexpected token <

Created on 27 Mar 2019  路  3Comments  路  Source: cypress-io/cypress

I have getting error after run this code.

sample_spec.js

describe('Vist testing', function() {
    it('finds the content "type"', function() {
      cy.visit('http://localhost:3000') 

      cy.contains('Sign in')

    })
  })

error screen is following
image

Please help .. who knows this solution?

Most helpful comment

If someone else runs into this in the future, mine was down to trying to load a non existent JS file(from my index page).

Adding this to the test file got me on the right track;

Cypress.on('uncaught:exception', (err, runnable) => {
  console.log(err);
  return false;
})

All 3 comments

Can you try opening your devtools to see if there are any errors printed there? This looks to be originating from your application code.

Generally I see this error in my applications when an XHR request responds with rather than what it's supposed to.

I found the issue reason.
My index.html includes jquery.js and it happen this issue.

image

I comment or remove the jquery line in index.html and rerun it.

Then, its issue goes away. :100:
I think my jquery has some issue.

Thanks @jennifer-shehane for your concern.

If someone else runs into this in the future, mine was down to trying to load a non existent JS file(from my index page).

Adding this to the test file got me on the right track;

Cypress.on('uncaught:exception', (err, runnable) => {
  console.log(err);
  return false;
})
Was this page helpful?
0 / 5 - 0 ratings