Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

_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

like image 248
Carlos Eduardo Ilgenfritz Avatar asked Dec 31 '22 07:12

Carlos Eduardo Ilgenfritz


2 Answers

Correct with this:

const store = new Vuex.Store({
    sateliteStore
})
like image 75
Anatoly Avatar answered Jan 10 '23 15:01

Anatoly


It should be Vuex.Store check the capitalization of the word store.

like image 24
Kipruto Avatar answered Jan 10 '23 16:01

Kipruto