I'm trying to test different parts of VueX store. I keep mutations, getters and else in single file (index.js) but somehow it does not work when import that file into test file. Here is my VueX: Vue.use(Vuex);
Index.js
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
export default new Vuex.Store({
state: {
pickedDates:[]
},
mutations: {
mutatePickedDates: (state, payload) => {
state.pickedDates = payload;
},
})
Now in Store.spec.js I want to test it:
import storeConfig from '@/store/index.js'
const store = storeConfig
test('check if state is working', () =>{
const state = {
pickedDates: []
}
const dates = ['1995-01-01', '1995-01-01']
store.mutations.mutatePickedDates(state, {dates})
expect(state.pickedDates).toBe(dates)
})
But I get error: TypeError: Cannot read property 'mutatePickedDates' of undefined when running test.