0👍
The vueTest
function in utils is trying to load the Vue instance into the body
tag:
const vm = new Class({
replace: false,
el: 'body'
})
return vm
The unit tests do not load index.html
as an entry point into the app, but rather the individual components that you want to test; Therefore, you do not have access to document
or html elements and the component is never mounted. I’d suggest using vm.$mount():
If elementOrSelector argument is not provided, the template will be rendered as an off-document element.
You could change the above lines to something like the following
const vm = new Class();
vm.$mount();
return vm;
Your tests should now have access to the $el property.
- [Vuejs]-Child not updating based on props in Vue.js
- [Vuejs]-How to add vote without refresh with vue.js?
Source:stackexchange.com