
Description
What problem does this feature solve?
While Vue Test Utils are great for testing components, there is currently no official testing environment agnostic API for
- mocking and asserting Vuex actions dispatched by a component
- mocking and asserting Vuex mutations committed by an Vuex action
The current testing guidelines for actions require to copy a helper function.
If an action returns a Promise, the helper currently does not support that (vuejs/vuex#939) which has lead to a modified helper in our code base (https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20513/diffs).
The current testing guidelines for components with Vuex require to manually create a new store and replace the actions with spies.
This leads to a lot of boilerplate in tests and therefore harder to maintain tests.
EDIT: the following content is outdated please see #1060 (comment)
Therefore I created Vuex Test Utils and would like to contribute them to Vue Test Utils.
- documentation: https://winh.gitlab.io/vuex-test-utils/
- source code: https://gitlab.com/winh/vuex-test-utils/tree/master/src
- example component test: https://gitlab.com/winh/vuex-test-utils/blob/master/example/test/components/header.spec.js
- example action tests: https://gitlab.com/winh/vuex-test-utils/blob/master/example/test/store/actions.spec.js
The project is currently missing unit tests (ironic I know!) which I plan to add after discussing the plan forward in this issue.
What does the proposed API look like?
Please see the documentation hosted at https://winh.gitlab.io/vuex-test-utils/.