-
Notifications
You must be signed in to change notification settings - Fork 278
Closed
Description
Hello,
I'm trying to setup tests for the component using mock vuex store, however i'm running into an issue where i get the following warning and subsequent error in setup function of the component.
Here is the sample component that i used to reproduce this issue
https://github.com/techlab23/task-management-app-ts/blob/tests/tests/App.spec.ts
[Vue warn]: injection "store" not found.
at <Anonymous ref="VTU_COMPONENT" >
at <VTUROOT>
16 | components: { AppHeader, AppLoadingIndicator },
17 | setup() {
> 18 | const store = useStore();
| ^
19 | store.dispatch('fetchData');
20 | const isLoading = computed<boolean>(() => store.getters.isLoading);
21 | return {
Following above error i get another error in calling a dispatch function
App › calls fetchData to load initial data
TypeError: Cannot read property 'dispatch' of undefined
17 | setup() {
18 | const store = useStore();
> 19 | store.dispatch('fetchData');
| ^
20 | const isLoading = computed<boolean>(() => store.getters.isLoading);
21 | return {
22 | isLoading,
at setup (src/App.vue:19:11)
Appreciate any pointers is resolving this issue.
Metadata
Metadata
Assignees
Labels
No labels