-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate 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! 👍 I would be happy to help adding that to vuex-mock-store if you like. |
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
The text was updated successfully, but these errors were encountered: