Description
- follow on from Support vite v5 for component testing #28347
Current behavior
Cypress Changelog 13.13.0 states "Added support for vite v5 to @cypress/vite-dev-server
."
Running Component Testing with Cypress and vite v5 or vite v6 results in the message:
The CJS build of Vite's Node API is deprecated.
Desired behavior
Running Component Testing with Cypress and vite v5 or v6 should not show any deprecation message related to Vite's Node API.
Test code to reproduce
See https://github.com/cypress-io/github-action/tree/master/examples/component-tests
To run, use the following:
git clone https://github.com/cypress-io/github-action
cd github-action
git clean -xfd # if repeating
cd examples/component-tests
npm ci
npm test
For debug info, repeat with:
export VITE_CJS_TRACE=true
npm test
See also #29557 (comment) for steps to reproduce without using an additional repository using npm/vite-dev-server
directly.
Cypress Version
First reported on version 13.10.0
Still reproducible on version 14.1.0
Node version
v20.13.1
v20.18.1
(issue is sensitive to Node.js version)
For instance, it does not reproduce on Node.js v22.14.0
GitHub Actions are locked to using node20
at this time. GitHub Actions does not currently offer any higher Node.js for JavaScript Actions to run in.
Operating System
Ubuntu 22.04.4
LTS
Ubuntu 22.04.5
LTS and 24.04.1
LTS
Debug Logs
$ export VITE_CJS_TRACE=true
npm test
> [email protected] test
> cypress run --component
DevTools listening on ws://127.0.0.1:41551/devtools/browser/d676f1ba-6901-4f0c-a113-4d46551aac70
Trace: The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
at warnCjsUsage (/home/mike/github/temp/github-action/examples/component-tests/node_modules/vite/index.cjs:33:3)
at Object.<anonymous> (/home/mike/github/temp/github-action/examples/component-tests/node_modules/vite/index.cjs:3:1)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at getVite (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/@packages/server/node_modules/@cypress/vite-dev-server/dist/getVite.js:14:16)
at devServer (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/@packages/server/node_modules/@cypress/vite-dev-server/dist/devServer.js:13:40)
at Object.handler (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:166:24)
at invoke (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:185:18)
at /home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:59:14
at tryCatcher (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/bluebird/js/release/util.js:16:23)
at Promise.attempt.Promise.try (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/bluebird/js/release/method.js:39:29)
at Object.wrapChildPromise (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:58:23)
at Object.wrap (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/dev-server.js:18:8)
at RunPlugins.execute (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:155:26)
at EventEmitter.<anonymous> (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:56:12)
at EventEmitter.emit (node:events:519:28)
at process.<anonymous> (/home/mike/.cache/Cypress/13.10.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)
at process.emit (node:events:519:28)
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 13.10.0 │
│ Browser: Electron 118 (headless) │
│ Node Version: v20.13.1 (/home/mike/n/bin/node) │
│ Specs: 1 found (Stepper.cy.jsx) │
│ Searched: **/*.cy.{js,jsx,ts,tsx} │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: Stepper.cy.jsx (1 of 1)
<Stepper />
✓ renders (60ms)
✓ stepper should default to 0 (36ms)
✓ supports a "count" prop to set the value (26ms)
✓ when the increment button is pressed, the counter is incremented (116ms)
✓ when the decrement button is pressed, the counter is decremented (111ms)
✓ clicking + fires a change event with the incremented value (110ms)
6 passing (530ms)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 6 │
│ Passing: 6 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: false │
│ Duration: 0 seconds │
│ Spec Ran: Stepper.cy.jsx │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ Stepper.cy.jsx 531ms 6 6 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! 531ms 6 6 - - -
Other
Installed npm module versions
├── @types/[email protected]
├── @types/[email protected]
├── @vitejs/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]