question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there any solution to use vite-jest for an application which using Vite + Vue2 + Composition API?

See original GitHub issue

If 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:open
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
sodateacommented, Dec 29, 2021

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.

2reactions
haug1commented, Mar 22, 2022

Would be cool to see this fixed 👀

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found