Search code examples
unit-testingvue.jsjestjsvuexvue-test-utils

_vuex.default.store is not a constructor


I'm trying to test a component that uses vuex inside it, I'm trying to pass the store of the respective component so that it can be assembled, but I'm getting the following error:

_vuex.default.store is not a constructor

I have no idea what's going on and I couldn't find anything on the internet to help me, if anyone can help me, I would be very grateful!

Spec file

import {shallowMount,createLocalVue} from '@vue/test-utils'
import Vuex from 'vuex'

import sateliteComponent from '@/components/satelite/listaSatelite.vue'
import sateliteStore from '@/core/modules/satelite/index.js'

var vueWithVuex = createLocalVue()
vueWithVuex.use(Vuex)
const store = new Vuex.store({
    sateliteStore
})
describe('testes componente satelite', () => {

    test('instanciado', () => {
        const wrapper = shallowMount(sateliteComponent,{
            localVue:vueWithVuex,
            store
        })
        expect(wrapper.isVueInstance()).toBeTruthy()

    });
});

if necessary, I can post my component that is being rendered


Solution

  • Correct with this:

    const store = new Vuex.Store({
        sateliteStore
    })