Closed re2005 closed 4 years ago
Seems pretty obvious like this:
import {createLocalVue, shallowMount} from '@vue/test-utils';
import Vuex from 'vuex';
import Header from '@/components/Header.vue';
const localVue = createLocalVue();
localVue.use(Vuex);
const getters = {
user: jest.fn()
};
const store = new Vuex.Store({
modules: {
user: {
namespaced: true,
getters
}
}
});
describe('Header.vue', () => {
it('Instantiate component', () => {
const wrapper = shallowMount(Header, {
store,
localVue
});
expect(wrapper.isVueInstance()).toBeTruthy();
});
});
I've posted the question on StackOverflow:
https://stackoverflow.com/questions/59245479/how-to-unit-test-a-typescript-vue-component-that-uses-vuex-class
Any help ?