title: How to use Jest with vuex-module-decorators
body: <p>I have a vue component written in Typescript where i import a vuex store that was written with vuex-module-decorators. My code works well but when i try to write a unit test using vue-test-utils and jest i'm not able to inject my store.</p>
  <p>Here is my vue component :</p>
  <p><code>mycomponent.vue</code></p>
  <pre><code>&lt;template&gt;
    &lt;v-autocomplete
       v-model=&quot;job
       :items=&quot;jobs&quot;
       outlined
       dense
       @change=&quot;editJob&quot;
    /&gt;
  &lt;/template&gt;
  &lt;script lang=&quot;ts&quot;&gt;
  import { Component, Vue } from 'vue-property-decorator'
  import { jobsWantedStore } from '../../utils/store-accessor'
  
  @Component
  export default class SelectJob extends Vue {
  
      async editJob() {
              try {
                  await jobsWantedStore.EDIT_JOB(this.job)
              } catch (error) {
                  this.error = error
              }
          }
      }
  
  }
  &lt;/script&gt;
  </code></pre>
  <p>The store :</p>
  <pre><code>/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
  import { Module, VuexModule, Action, Mutation, getModule } from 'vuex-module-decorators'
  import { PrioritisedJob } from '~/models'
  import JobsWantedService from '~/services/jobs-wanted-service'
  
  @Module({
      name: 'jobsWanted',
      stateFactory: true,
      namespaced: true,
  })
  export default class JobsWanted extends VuexModule {
      jobsWanted: Array&lt;PrioritisedJob&gt; = []
  
      // Getters
      public get JobsWanted(): Array&lt;PrioritisedJob&gt; {
          return this.jobsWanted
      }
  
      // Mutations
      @Mutation
      setJobs(jobsWanted: Array&lt;PrioritisedJob&gt;): any {
          this.jobsWanted = jobsWanted
      }
  
      @Mutation
      setJob(jobWanted: PrioritisedJob): any {
          this.jobsWanted = this.jobsWanted.map((job) =&gt; {
              if (jobWanted.id === job.id) {
                  return jobWanted
              }
              return { ...job }
          })
      }
  
  
      @Action({ rawError: true })
      public async EDIT_JOB(newJob: PrioritisedJob): Promise&lt;any&gt; {
          try {
              const job = await JobsWantedService.editJob(newJob)
              this.setJob(job)
          } catch (error) {
              throw error.response
          }
      }
  }
  </code></pre>
  <p>Store accessor :</p>
  <pre><code>/* eslint-disable import/no-mutable-exports */
  import { Store } from 'vuex'
  import { getModule } from 'vuex-module-decorators'
  import jobsWanted from '../store/jobsWanted'
  
  let jobsWantedStore: jobsWanted
  
  function initialiseStores(store: Store&lt;any&gt;): void {
      jobsWantedStore = getModule(jobsWanted, store)
  }
  
  export { initialiseStores, jobsWantedStore }
  </code></pre>
  <p>Here is my test file :</p>
  <p><code>job.spec.js</code></p>
  <pre><code>import { shallowMount, createLocalVue } from '@vue/test-utils'
  import mycomponent from '@/components/mycomponent.vue'
  import Vuetify from 'vuetify'
  import Vuex from 'vuex'
  
  const localVue = createLocalVue()
  const vuetify = new Vuetify()
  localVue.use(Vuex)
  
  describe('SelectJob', () =&gt; {
      let wrapper
      let store
      let actions
      let model
  
      beforeEach(() =&gt; {
      
          actions = {
              EDIT_JOB: jest.fn(),
          }
          store = new Vuex.Store({
              modules: {
                  jobsWanted: {
                      namespaced: true,
                      actions,
                  },
              },
          })
          wrapper = shallowMount(SelectJob, {
              propsData,
              vuetify,
              store,
          })
      })
      it('should edit a job', () =&gt; {
          wrapper.vm.editJob()
          try {
              expect(actions.EDIT_JOB).toHaveBeenCalled()
          } catch (e) {
              expect(e).toMatch('error')
          }
      })
  })
  </code></pre>
  <p>It tells me that it received 0 number of calls, and it's because <code>jobsWantedStore</code> is <code>undefined</code> when i run my tests. Anyone knows how to inject a store properly using vuex-module-decorators ?</p>