Is there any solution to use vite-jest for an application which using Vite + Vue2 + Composition API?
See original GitHub issueIf Vite + Vue2 is not vite-jest support target, I’ll close this issue.
I got this error when I run vite-jest
$ ./node_modules/.bin/vite-jest
(node:16061) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Determining test suites to run...Pre-bundling dependencies:
@vue/composition-api
....
(...and 56 more)
(this will be run only when your dependencies or config have changed)
> node_modules/@vue/composition-api/dist/vue-composition-api.esm.js:1:16: error: Could not read from file: /home/me/vite-vu2-app/vue/dist/vue.esm-bundler.js
1 │ import Vue from 'vue';
╵ ~~~~~
Error: Build failed with 1 error:
node_modules/@vue/composition-api/dist/vue-composition-api.esm.js:1:16: error: Could not read from file: /home/me/vite-vu2-app/vue/dist/vue.esm-bundler.js
at failureErrorWithLog (/home/me/vite-vu2-app/node_modules/esbuild/lib/main.js:1493:15)
at /home/me/vite-vu2-app/node_modules/esbuild/lib/main.js:1151:28
at runOnEndCallbacks (/home/me/vite-vu2-app/node_modules/esbuild/lib/main.js:941:63)
at buildResponseToResult (/home/me/vite-vu2-app/node_modules/esbuild/lib/main.js:1149:7)
at /home/me/vite-vu2-app/node_modules/esbuild/lib/main.js:1258:14
at /home/me/vite-vu2-app/node_modules/esbuild/lib/main.js:629:9
at handleIncomingPacket (/home/me/vite-vu2-app/node_modules/esbuild/lib/main.js:726:9)
at Socket.readFromStdout (/home/me/vite-vu2-app/node_modules/esbuild/lib/main.js:596:7)
at Socket.emit (node:events:390:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:199:23)
My environment
$ node --version
v16.13.0
$ jq .version node_modules/vite/package.json
"2.7.7"
$ jq .version node_modules/vue/package.json
"2.6.14"
$ jq .version node_modules/@vue/composition-api/package.json
"1.0.4"
$ grep preset jest.config.js
preset: "vite-jest",
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Getting Started - Vite
A build command that bundles your code with Rollup, pre-configured to output highly optimized static assets for production. Vite is opinionated and comes...
Read more >Testing - Vue.js
Jest is a popular unit testing framework, and can be made to work with Vite via the vite-jest package. However, we only recommend...
Read more >Getting Started with Vitest | Vue Mastery
In this Vitest tutorial, we'll look at why you'd want to use Vitest and how to get started using it to test your...
Read more >Vite cannot find module 39nodepath - mirage-air
The Composition API is an addition to the Vue framework created to address the limitations of the Options API used in Vue 2....
Read more >vue cannot find module
I used F7 cli to create a PWA type F7 with Vue But when npm run start or npm run ... そのため、特別Composition APIを使う必要がなければ、...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The errors here are because that I added some default options to the vite server but didn’t realize they are Vue-3 only.
But there are some other issues that prevent vite-jest from supporting the vue2 plugin🤔 I’ll take a look.
Would be cool to see this fixed 👀