Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upDeprecate testAction helper in favor of vuex-mock-store #1562
Comments
@posva What do you think? |
I think my mock doesn't cover testing actions so far. To be honest, when testing actions I always pass things manually using I was thinking of adding some kind of api to generate a context that call other actions and mutations: posva/vuex-mock-store#9 |
@posva Thanks for the fast reply!
Ignoring Vuex modules for now (which aren't supported by the existing
Isn't that exactly what your mock store does with |
but the Store mock can mock the whole store so you don't care about it in components. |
@posva You are only advertising vuex-mock-store for unit testing components but I think it can be used to unit test actions, too, because it has all we need. When unit testing actions, we want to mock away the state, getters, and mutations. All of that is already supported by vuex-mock-store. Here is a working example project: https://gitlab.com/winniehell/vue-examples/blob/master/vuex-mock-action-tests/test/store/actions.spec.js |
oh right, you pass the store to the action, I didn't see that! That's neat. Adding support for rootState and rootGetters could be added as well either directly on the store or with a |
@posva Do you think that is a requirement to replace the
I think such a method would be cleaner.
I agree! |
What problem does this feature solve?
The officially documented way to test actions
What does the proposed API look like?
Recommend to use https://github.com/posva/vuex-mock-store instead.
see also vuejs/vue-test-utils#1060