Vue testing library depends on vuex and vue-router types
See original GitHub issueHi there! For my surprise importing the @testing-library/vue
module raises a compilation error due to a dependency with vue-router
and vuex
.
ERROR Failed to compile with 2 errors
These dependencies were not found:
* vue-router in ./node_modules/@testing-library/vue/dist/vue-testing-library.js
* vuex in ./node_modules/@testing-library/vue/dist/vue-testing-library.js
To install them, you can run: npm install --save vue-router vuex
[=========================] 100% (completed)
WEBPACK Failed to compile with 2 error(s)
Error in ./node_modules/@testing-library/vue/dist/vue-testing-library.js
Module not found: 'vue-router' in '/home/sam/sandbox/opencocos/app/node_modules/@testing-library/vue/dist'
Error in ./node_modules/@testing-library/vue/dist/vue-testing-library.js
Module not found: 'vuex' in '/home/sam/sandbox/opencocos/app/node_modules/@testing-library/vue/dist'
I’ve tried installing both dependencies and test pass, but I believe it shouldn’t be mandatory in order to run tests, right?
Notice: I’m not using Jest. I’m running tests with Mocha.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Mocking Vuex in Vue unit tests - Medium
Vue is a UI library — so naturally, testing Vue components usually involves asserts whether the UI correctly reflects the state of the...
Read more >Chapter 7. Testing Vuex - Testing Vue.js Applications
Vuex (a state-management library for Vue) is essential for large Vue apps. To become a Vue testing master, you should learn how to...
Read more >Vue.js Testing Made it Easy (with Testing Library) - maxpou.fr
It's not an easy job since Vuex is based on mutations. Without these lines, you may have problems where test #3 depends on...
Read more >Testing - Vue.js
Each testing type plays a role in your application's testing strategy and ... Vitest is a unit testing framework designed specifically for this...
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 FreeTop 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
Top GitHub Comments
Wouldn’t that generate several warnings on loose types if we change the complex ones to
any
, for instance?no-unsafe-assignment
orno-unsafe-call
being some of them.Would you define
store
androutes
asany
(or anything similar) and call it a day?Looks like it is due to VTL types making use of TS definitions from both Router and Vuex. Not sure how to fix this one – maybe simply copy&pasting these types from both libraries into VTL, so that the dependency can go?
https://github.com/testing-library/vue-testing-library/blob/master/types/index.d.ts#L3-L6