In order to mock a Vuex store with Jest, you essentially have to build a whole Vuex store that replicates what your existing Vuex store does. Below are how you mock each of the different types of functions in a Vuex store.
import Vuex from "vuex";
import { shallowMount, createLocalVue } from '@vue/test-utils'
const actions = {
myAction: jest.fn()
};
const store = new Vuex.Store({
actions
});
const localVue = createLocalVue();
localVue.use(Vuex);
const wrapper = shallowMount(MyComponenet, { store, localVue });
import Vuex from "vuex";
import { shallowMount, createLocalVue } from '@vue/test-utils'
const getters = {
myData: () => [2, 4, 5, 6]
};
const store = new Vuex.Store({
getters
});
const localVue = createLocalVue();
localVue.use(Vuex);
const wrapper = shallowMount(MyComponent, { store, localVue });