How can I unit-test a pinia store getters and actions? #2546
Unanswered
roshmani
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am new to pinia and vitest , I tried a few things based on the document, i am not sure if it is the right way.
I am trying to test an action in pinia eg:-
which calls an open-api function (axios call) as follows :
This test seems to work. I would like to assert the value in the state (
this.settings
) somehow . How can i do that?I also tried to mock the error for the same action which goes to the catch block.
For that I tried :
It fails, is there any way i can mock an error from the api call ? and also what is the right way to test the getters and actions ?
TIA
Beta Was this translation helpful? Give feedback.
All reactions