I'm testing an application with vuex, I have a main store and a module, everything works fine in the application itself, but when I use tests I get a warning.
console.warn [vuex] state field "institutes" was overridden by a module with the same name at "institutes"
main store
export const state = {}
export default new Vuex.Store({
state,
mutations,
actions,
getters,
modules: {
institutes
}
})
secondary store
export const stateInst = {}
export default {
namespaced: true,
state: () => stateInst,
mutations,
actions
}
test.spec.js
import Vuex from "vuex"
import {mount, createLocalVue} from "@vue/test-utils"
import Institutes from '../../assets/src/components/Institutes'
import { state } from '../../assets/src/store/index'
import { stateInst } from '../../assets/src/store/institutes-store'
const localVue = createLocalVue()
localVue.use(Vuex)
describe('testing component', () => {
let store
beforeEach(() => {
store = new Vuex.Store({state,
modules: {
institutes: {
namespaced: true,
state: () => stateInst,
mutations,
actions,
}
}
})
})
test('some test', async () => {
const wrapper = mount(Institutes, {
store, localVue
})
})
})
I tried to follow the advice as given in the documentation but it either doesn't work or breaks my application. enter link description here