'How do I use Vue3 with vue-jest?

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: [email protected]
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 [email protected]
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?



Solution 1:[1]

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

Solution 2:[2]

since jest v27,use vue3-jest instead.

npm i vue3-jest

feat: support jest v27 in vue3-jest #343

Solution 3:[3]

To fix this use the latest @vue/vue3-jest package. NOT vue3-jest.

Read more here: vue test utils TypeError: Cannot destructure property `config` of 'undefined' or 'null'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ahmed Rafik Ibrahim
Solution 2 Li Kui
Solution 3 snoob dogg