You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
I have some composable that uses a store. I would like to test the code with jest and mock the store with some predefined values. As we don't mount a composable I'm not sure how to proceed.
I was researching and just found some answers to Pinia but not for Vuex (like setActivePinia).
Hi
@gabriellatavares
We have a dedicated guide for testing Vuex but it's more focused on testing components that use a store
https://test-utils.vuejs.org/guide/advanced/vuex.html
You're indeed going to find more answers around Pinia, as it is the recommended solution over Vuex in Vue 3, but the principles should be the same
Testing a composable can be done by creating a test component that uses it, and then mounting and testing this component.
When you mount the component, you can then mock the store as explained in the guide I linked above.
Hi
@gabriellatavares
We have a dedicated guide for testing Vuex but it's more focused on testing components that use a store
https://test-utils.vuejs.org/guide/advanced/vuex.html
You're indeed going to find more answers around Pinia, as it is the recommended solution over Vuex in Vue 3, but the principles should be the same
Testing a composable can be done by creating a test component that uses it, and then mounting and testing this component.
When you mount the component, you can then mock the store as explained in the guide I linked above.