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

Cypress Cannot Determine Configuration of Project or Run Tests for Vite React Yarn (pnp) #24597

Closed
briggsge opened this issue Nov 8, 2022 · 1 comment

Comments

@briggsge
Copy link

briggsge commented Nov 8, 2022

Current behavior

  • Cypress cannot detect dependencies for react, react-dom, or vite
    • Cypress has a separate issue with Yarn Zero-Installs where installed dependencies are not detected by Cypress
    • this is due to yarn Zero-Installs not requiring a package-lock.json or a node_modules directory and is resolved by running npm it but should be handled by cypress searching .yarn/cache as a default for yarn runs.
  • Cypress cannot resolve Vite .env configs for Vite | React | Yarn (pnp) app
  • Tests hang indefinitely due to the use of Vite over Webpack in the cypress.config.js file
  • Cannot read in vite .env file params using webpack so tests cannot run
  • Cypress example tests for cypress.config.ts cannot resolve commands.ts in the auto-generated component.ts file due to the file extension being excluded
    • fixed by just appending '.ts' on the import after instal (minor issue)

Desired behavior

Cypress should run tests and provide error outputs if the tests fail or finish executing tests

Test code to reproduce

Zero-Installs for yarn v3 is configured by setting

nodeLinker: pnp

in the .yarnrc.yml file

Cannot get to the point of running tests with the code below but I cannot provide the original code base that failed to execute tests.

Note that react, react-dom, and vite are in package.json but for the before code base, cypress does not detect those dependencies are installed.

Below zip is before completing the initial Cypress config

cypressBeforeSetupYarnViteReact.zip

The following zip is after running

yarn cypress open

and going through the config process

cypressAfterConfigYarnViteReact.zip

Cypress Version

10.11.0

Node version

v18.10.0, v18.7.0

Operating System

Windows 10, MacOS

Debug Logs

Could not find "vite" in your project's dependencies. Please install "vite" to fix this error.

Error: Cannot find module 'vite'
Require stack:
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/vite-dev-server/dist/getVite.js
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/vite-dev-server/dist/devServer.js
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/vite-dev-server/dist/index.js
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/vite-dev-server/index.js
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/require_async_child.js
Error: Could not find "vite" in your project's dependencies. Please install "vite" to fix this error.

Error: Cannot find module 'vite'
Require stack:
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/vite-dev-server/dist/getVite.js
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/vite-dev-server/dist/devServer.js
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/vite-dev-server/dist/index.js
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/vite-dev-server/index.js
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js
- /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/require_async_child.js
    at getVite (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/vite-dev-server/dist/getVite.js:17:15)
    at devServer (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/vite-dev-server/dist/devServer.js:12:40)
    at Object.handler (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:166:24)
    at invoke (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:43:18)
    at /Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:59:14
    at tryCatcher (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at Object.wrapChildPromise (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:58:23)
    at Object.wrap (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/dev-server.js:18:8)
    at RunPlugins.execute (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:172:26)
    at EventEmitter.<anonymous> (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:279:12)
    at EventEmitter.emit (node:events:390:28)
    at process.<anonymous> (/Users/gregbriggs/Library/Caches/Cypress/10.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
    at process.emit (node:events:390:28)
    at emit (node:internal/child_process:917:12)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

Other

I think another bug will need to be logged once the code provided can get to running tests. Vite is installed but the debug log is showing Cypress cannot find the dependency.

Note: Edited to remove some syntax errors. Apologies for the rushed submission. Keep up the good work!

@rockindahizzy
Copy link
Contributor

Hey @briggsge, thanks for opening this issue! I am closing this as a duplicate of #22747. If there are additional details you'd like to point out, feel free to reopen this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants