Mocking getters using TypeScript and Composition API #1835
-
Hi all, I have this store:
How can I mock for each test the value of the getter (computed property)? As far as I know, inside a store using composition API with script setup, the computed properties act as getters.
My test works fine reading the I assume does not work because this function only merges reactive properties. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think the initialState property is really just for the "state" so in your case "current". The Getter (in your case the computed) needs to be overwritten inside the tests itself like this.
I hope this helps |
Beta Was this translation helpful? Give feedback.
I think the initialState property is really just for the "state" so in your case "current".
The Getter (in your case the computed) needs to be overwritten inside the tests itself like this.
There is a small hint inside the docs: https://pinia.vuejs.org/cookbook/testing.html#mocking-getters