"[Vue warn]: Unknown custom element:" when running unit tests
See original GitHub issueI’ve imported Vuetify in my main.js file:
import Vue from 'vue';
import VueResource from 'vue-resource';
import Vuetify from 'vuetify';
import App from './App';
import router from './router';
Vue.use(Vuetify);
Vue.use(VueResource);
When I run any Karma unit tests that test components that include Vuetify elements in their templates I get the following errors:
The test itself actually passes, I would just like to clean this up.
Any ideas? Is there another way to register Vuetify components for testing purposes? Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Vuetify Jest Unknown custom element <v-*> - Stack Overflow
It looks like a autogenerated bug when generating Vuetify project from the CLI . In short, it's because Vuetify is not registered in...
Read more >5 mins to fix jest tests for app with: Unknown custom element
If you are writing unit tests and want to test the functionality of a component individually, then setup the shallowMount function and test...
Read more >Vue Test Utils: [Vue warn]: Unknown custom element: <v ...
I get this error message: [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to ......
Read more >Vue+jest+Vuetify 2.0.*+unit testing : Getting an error as "[Vue ...
This error occurs because vuetify is not registered to your test project. To do so you have to create an index.js file in...
Read more >Quasar Unknown custom element error in unit test-Vue.js
Coding example for the question Quasar Unknown custom element error in unit test-Vue.js.
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
Solved! Correct, Vuetify was not getting registered. So I added:
in the test file itself but that still caused issues. So I dug into the Vuetify index.js file and saw this:
And because my karma config was setup to use PhantomJS as the browser there was no ‘window’. So I changed it to use ‘Chrome’ and it now works fine.
Another alternative I found was to add:
to the test file and include any failing components.
Hope this helps others!
for me, I had to add this in my setup file