How do I use Vue3 with vue-jest?

Viewed 4934

I have the following dependency...

"vue-jest": "latest",

But when I run npm install I get...

npm WARN ERESOLVE overriding peer dependency
npm WARN Found: vue@3.1.4
npm WARN node_modules/vue
npm WARN   vue@"latest" from the root project
npm WARN   7 more (@headlessui/vue, @heroicons/vue, @vue/compiler-sfc, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer vue@"^2.x" from vue-jest@3.0.7
npm WARN node_modules/vue-jest
npm WARN   dev vue-jest@"latest" from the root project

I looked at the code and I see a lib called vue3-jest but that isn't available in npm...

What is the proper way to get the version of vue-jest that uses vue3?

3 Answers

Depending on what Vue Test Utils for Vue3 installation guide, you should use vue-jest v5 that is still in alpha because it's the one that supports Vue 3.

The latest version is 3.0.7. But the version you need is 5.0.0-alpha.10. It exists in the next channel so you should be able to install it using:

npm i vue-jest@next

You can check all vue-jest versions here https://www.npmjs.com/package/vue-jest in the Versions tab

Related