Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
'TypeError: Cannot read properties of undefined (reading 'getters')' occurs in vue-test-utils

I'm testing Vue project with vue-test-utils and jest.

...
export default Vue.extend({
  components: { MemoInputAndButton, DomeMemoLine },
  data (): {
    memoLineList: Array<IMemoLine>
  } {
    return {
      memoLineList: []
    }
  },
  computed: {
    ...mapGetters('fraudTransactionState', {
      fraudTransactionDetail: FraudTransactionGetters.FraudTransactionDetail
    })
  },
  created: async function () {
    await this.setMemoLineList()
  },
  methods: {
    ...mapActions('fraudTransactionState', {
      postFraudTransactionMemo: FraudTransactionActions.PostFraudTransactionMemo
    }),
    async onMemoInputted (input: string): Promise<void> {
      await this.postMemo(input)
    },
...

MemoTimelineSection.vue

It uses vuex in modules which is namespaced: true!

const localVue = createLocalVue()
localVue.use(ElementUI)
localVue.use(Vuex)

describe('MemoTimelineSection', () => {
  const div = document.createElement('div')
  div.id = 'root'
  document.body.appendChild(div)

  let wrapper

  let getter = {
    'FRAUD_STATICS': () => { },
    'FRAUD_TRANSACTIONS': () => { },
    'FRAUD_TRANSACTION_DETAIL': () => { }
  }
  let store

  beforeEach(() => {
    ...
    const div = document.createElement('div')
    div.id = 'root'
    document.body.appendChild(div)
    ...

    store = new Vuex.Store({
      modules: {
        fraudTransactionState: {
          getter,
          namespaced: true
        }
      }
    })

MemoTimelineSection.test.js

and actual vuex store is

export const store: StoreOptions<RootState> = {
  state: {
   ...
  },
  mutations: {
   ...
  },
  actions: {},
  modules: {
    transfersStore,
    fraudTransactionState
  },
  getters: {}
}

export default new Vuex.Store<RootState>(store)

index.ts

When I run the test file,

● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'getters')

      33 | console.log('run')
      34 |
    > 35 | export default new Vuex.Store<RootState>(store)
         |                ^
      36 |

occurs.

When I remove mapGetters and mapActions from Vue code, this error doesn't appear so I think it's related to mapGetters or mapActions or something related to Vuex...

The other code, which doesn't use vuex store in modules(only in roots) and is composed of vue-class-component, is running correctly even though it also tests vuex.

How can I solve it? Thx in advance.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda