Mocking store with vitest and composition API #2092
Replies: 4 comments
-
I have exactly the same problem and don't how to solve this. |
Beta Was this translation helpful? Give feedback.
-
I found a solution using the vuex docs. Perhaps it could be of help? |
Beta Was this translation helpful? Give feedback.
-
Have you check the typo? you use darMode in createTestingPinia but inside the store is darkMode const testingPinia = createTestingPinia({
createSpy: vi.fn(),
initialState: {
style: {
darMode: true,
},
},
}) and export const useStyleStore = defineStore("style", {
state: () => ({
/* Styles */
navBarItemLabelActiveColorStyle: "",
overlayStyle: "",
/* Dark mode */
darkMode: true,
}),
... |
Beta Was this translation helpful? Give feedback.
-
In my particular situation, I encountered a plugin error that was not properly registered in the global.plugins:[“someMissingPlugin”]. As a result, this led to an undefined error, despite it not being related to a store error. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a simple AdsView.vue that I'd like to test
My test code
I'm trying to get it working but I keep getting
The store is simple
How to mock my style store? I tried vi.mock, pinia/testing plugin, changing paths. What am I missing?
Beta Was this translation helpful? Give feedback.
All reactions