I read vue-utils-test documentation 3 times and documentation of jest too, But I do not get idea how exactly mock the vue mixins in vue component and test the component.
Mixins can be tested by creating a mock component and registering the mixin on the component. Mixins can be applied globally or locally on a component. You can register filters and mixins before running unit tests. You can test filters and mixins in components by testing component output.
Vue Test Utils is the official unit testing utility library for Vue. js. This is the documentation for Vue Test Utils v1, which targets Vue 2 and earlier.
There are two ways:
const localVue = createLocalVue() localVue.mixin(myMixin) const wrapper = shallow(Post, { localVue, })
mixins
in the mounting options:const wrapper = shallow(Post, { mixins: [myMixin], })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With