Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

> Unexpected token '<' error w/ cypress component testing #22108

Closed
nadvolod opened this issue Jun 4, 2022 · 2 comments
Closed

> Unexpected token '<' error w/ cypress component testing #22108

nadvolod opened this issue Jun 4, 2022 · 2 comments
Assignees
Labels
stage: awaiting response Potential fix was proposed; awaiting response

Comments

@nadvolod
Copy link

nadvolod commented Jun 4, 2022

Current behavior

I'm trying to follow the component testing docs to get started but facing the error below. This is the code .

The following error originated from your test code, not from Cypress.
  > Unexpected token '<'
at Object.runScripts (http://localhost:3001/__cypress/runner/cypress_runner.js:179586:63)
at $Cypress.onSpecWindow (http://localhost:3001/__cypress/runner/cypress_runner.js:167795:77)
at <unknown> (http://localhost:3001/__cypress/iframes//Users/nikolay/source/js/js-code/cy-10/cypress/component/Stepper.cy.js:59:18)

Desired behavior

I believe that the component should mount just fine without issues.

Test code to reproduce

https://github.com/nadvolod/js-code/tree/cypress_10/cy-10

Cypress Version

10.0.2

Other

Cy component testing

  "dependencies": {
    "react": "^18.0.0",
    "react-dom": "^18.0.0"
  },
  "devDependencies": {
    "@types/react": "^18.0.0",
    "@types/react-dom": "^18.0.0",
    "@vitejs/plugin-react": "^1.3.0",
    "cypress": "^10.0.2",
    "vite": "^2.9.9"
  }
@mschile
Copy link
Contributor

mschile commented Jun 5, 2022

@nadvolod, thanks for logging this issue. I checked out your code and since jsx is used within the test file, it should be named Stepper.cy.jsx not Stepper.cy.js. After making this change, the tests should pass.

@cypress-bot cypress-bot bot added the stage: awaiting response Potential fix was proposed; awaiting response label Jun 5, 2022
@mschile mschile self-assigned this Jun 5, 2022
@nadvolod
Copy link
Author

nadvolod commented Jun 5, 2022

@mschile beautiful! Thank you

@nadvolod nadvolod closed this as completed Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: awaiting response Potential fix was proposed; awaiting response
Projects
None yet
Development

No branches or pull requests

2 participants