vuex-module-decorators icon indicating copy to clipboard operation
vuex-module-decorators copied to clipboard

How to mock a store module instance?

Open souphuhn opened this issue 4 years ago • 0 comments

Hello everyone,

I have a fixed instance of my store module which I use in my Vue components and outside of Vue in some typescript files. Regarding unit tests I want to mock this instance in order to test my Vue component. I want to set its states and mock its getters. So far I was able to mock its states but I failed to somehow mock its getters

I have the following environment:

MyModule.ts:

@Module({ name: 'myModule ', namespaced: true, dynamic: true, store: globalStore})
export class MyModule extends VuexModule {

}

export const myModuleInstance = getModule(MyModule , globalStore);

My question is, if anyone already mocked such module instance like myModuleInstance within a test? If I take a look in that module instance, then I see that it become quite complex compared to my class-syntax. So I wonder if it is even possible to mock it?? Any help?

souphuhn avatar Aug 13 '20 11:08 souphuhn