State not updating in Unit Tests when it's set in onmounted #2972
-
Reproductionhttps://codesandbox.io/p/github/Yodablues/test-pinia-not-updating/main?import=true Steps to reproduce the bugI've created a codesandbox showing how this doesn't seem to work correctly. In it, I have App.vue with a onBeforeMounted hook calling an action to set some state in pinia. Then in another lifecycle hook, we check the state and it is undefined. Am i just doing this test wrong?
Expected behaviorThe pinia state should be updated. Actual behaviorThe state is not updated. Additional informationNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You need to pass |
Beta Was this translation helpful? Give feedback.
You need to pass
stubActions: false
to your test. https://pinia.vuejs.org/cookbook/testing.html#Customizing-behavior-of-actions