Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
Jest test vuex state was overridden by a module with the same name

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

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda