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

Component tests fail with React + TS + Vite 4.2.0 #26153

Closed
ae9is opened this issue Mar 19, 2023 · 4 comments
Closed

Component tests fail with React + TS + Vite 4.2.0 #26153

ae9is opened this issue Mar 19, 2023 · 4 comments
Labels
type: duplicate This issue or pull request already exists

Comments

@ae9is
Copy link

ae9is commented Mar 19, 2023

Current behavior

All component tests seem to fail when using React + TS + Vite 4.2.0 (4.1.4 is fine) if the mount command in cypress/support/component.ts is defined.

A generic error message is thrown:

An uncaught error was detected outside of a test:
     TypeError: The following error originated from your test code, not from Cypress.

  > Failed to fetch dynamically imported module: http://localhost:5173/__cypress/src/cypress/support/component.ts

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

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.

If cypress/support/component.ts is modified to comment out the custom mount comment (Cypress.Commands.add('mount', mount)), then the issue does not occur. (Simple tests without using mount() can pass.) With the mount command, all tests error.

Desired behavior

Component tests using mount ideally should work with Vite 4.2.0

Test code to reproduce

See: https://github.com/ae9is/cypress-component-testing-apps

This is just a fork of the React + Vite + TS component testing example app https://github.com/cypress-io/cypress-component-testing-apps/tree/main/react-vite-ts modified to bump Cypress to 12.8.1 and Vite to 4.2.0.

Cypress Version

12.8.1

Node version

18.12.1

Operating System

Ubuntu 22.04

Debug Logs

No response

Other

No response

@lmiller1990
Copy link
Contributor

lmiller1990 commented Mar 19, 2023

Yep, please see: #26149 (comment)

Fixed in #26139. This will be in the next release, within 2 weeks. You can use Vite 4.1 in the meantime. Thanks!

I'll leave this open to prevent duplicates, since a lot of people are running into this. Please be patient 🙏

@ae9is
Copy link
Author

ae9is commented Mar 20, 2023

Great, thanks! Sorry about the duplicate, wasn't sure if those were the same issue and wanted to save people some time in case they also ran into this.

@Ancient-Dragon
Copy link

We get this with vue and vite. It fails the first run then because we have retires we get another error:

Cannot read properties of undefined (reading 'prevAttempts') at replacePreviousAttemptWith (http://localhost:5173/__cypress/runner/cypress_runner.js:167740:40) at Object.onRunnableRun (http://localhost:5173/__cypress/runner/cypress_runner.js:167879:11) at $Cypress.action (http://localhost:5173/__cypress/runner/cypress_runner.js:157260:28) at Runnable.run (http://localhost:5173/__cypress/runner/cypress_runner.js:166040:13) at ../driver/node_modules/mocha/lib/runner.js.Runner.runTest (http://localhost:5173/__cypress/runner/cypress_runner.js:115099:10) at http://localhost:5173/__cypress/runner/cypress_runner.js:115225:12 at next (http://localhost:5173/__cypress/runner/cypress_runner.js:115008:14) at http://localhost:5173/__cypress/runner/cypress_runner.js:115018:7 at next (http://localhost:5173/__cypress/runner/cypress_runner.js:114920:14) at http://localhost:5173/__cypress/runner/cypress_runner.js:114986:5 at timeslice (http://localhost:5173/__cypress/runner/cypress_runner.js:108912:27)

Cypress version: 12.17.2
Vite version: 4.4.7
Vue version: 3.3.4

@jennifer-shehane
Copy link
Member

Fixed in #26139. Closing as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

5 participants