testing-library / vue-testing-library

🦎 Simple and complete Vue.js testing utilities that encourage good testing practices.
http://testing-library.com/vue
MIT License
1.07k stars 111 forks source link

Installing on Nuxt / Vue2 project following the docs fails due to wrong test-utils version #265

Closed lbsn closed 2 years ago

lbsn commented 2 years ago

Describe the bug

I'm using vue-testing-library with Nuxt and Vue2. Based on the docs installation should be done using the command:

npm install --save-dev @testing-library/vue

That will install the latest version of @testing-library/vue (currently 6.5.1) which under the hood is using version 2.0.0-rc.18 of @vue/test-utils. This version of test-utils is not compatible with Vue2 (v1 should be used instead) and results in error when running the test suite:

Cannot find module '@vue/compiler-dom' from 'node_modules/@testing-library/vue/node_modules/@vue/test-utils/dist/vue-test-utils.cjs.js'

Apparently the latest version of @testing-library/vue compatible with Nuxt / Vue2 is 5.8.2 and that should probably be clarified in the docs.

To Reproduce

Related information:

rordi commented 2 years ago

I just run into the same problem, but you can install from the v5 version, i.e. "@testing-library/vue": "^5.8.0".

As per the release tags in this repo it seems the latest v6 track is for Vue 3 while the v5 track is for Vue 2.

lbsn commented 2 years ago

I just run into the same problem, but you can install from the v5 version, i.e. "@testing-library/vue": "^5.8.0".

As per the release tags in this repo it seems the latest v6 track is for Vue 3 while the v5 track is for Vue 2.

Sure, I was rather pointing out that the docs are inaccurate on this point. And it seems to me that the information is nowhere to find, one has to look at the package.json in order to know that v5 is for Vue 2.

machadodev commented 2 years ago

I was having the same problem here. Thank you for clarifying. v5.8.2 worked for me.

afontcu commented 2 years ago

Docs updated. thanks everyone.