Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
'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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!