Skip to content

Add a way to mock Vuex stores #1060

Closed
@ghost

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.

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/.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions