Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Incognitus-Io/vuex-test-utils
Testing utils for Vuex
https://github.com/Incognitus-Io/vuex-test-utils
Last synced: about 1 month ago
JSON representation
Testing utils for Vuex
- Host: GitHub
- URL: https://github.com/Incognitus-Io/vuex-test-utils
- Owner: Incognitus-Io
- License: mit
- Created: 2019-10-04T14:30:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T00:32:21.000Z (11 months ago)
- Last Synced: 2024-01-08T08:51:03.472Z (5 months ago)
- Language: TypeScript
- Size: 785 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Lists
- awesome-vue - vuex-test-utils - Unit testing Vux with chai. (Components & Libraries / Dev Tools)
- awesome-vue - vuex-test-utils - Unit testing Vux with chai. (Components & Libraries / Dev Tools)
- awesome-vue - vuex-test-utils - Unit testing Vux with chai. (Components & Libraries / Dev Tools)
- awesome-vue - vuex-test-utils - Unit testing Vux with chai. (Components & Libraries / Dev Tools)
- awesome-vue - vuex-test-utils - Unit testing Vux with chai. (Components & Libraries / Dev Tools)
- awesome-vue - vuex-test-utils - Unit testing Vux with chai. (Components & Libraries / Dev Tools)
- awesome-vue - vuex-test-utils - Unit testing Vux with chai. (Components & Libraries / Dev Tools)
- awesome-vue - vuex-test-utils - Unit testing Vux with chai. (Components & Libraries / Dev Tools)
- awesome-vue - vuex-test-utils - Unit testing Vux with chai. (Components & Libraries / Dev Tools)
- awesome-vue - vuex-test-utils - Unit testing Vux with chai. (Components & Libraries / Dev Tools)
README
# Vuex-Test-Utils
![](https://github.com/Incognitus-Io/vuex-test-utils/workflows/Node%20CI/badge.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/Incognitus-Io/vuex-test-utils/badge.svg)](https://coveralls.io/github/Incognitus-Io/vuex-test-utils)
This is a collection of test utilities for vuex. For actions you can check if things are commited or dispatched, and what their payload was.## Getting started
1. install using `yarn add -D @incognitus/vuex-test-utils`
2. configure `jest.config.js`
```javascript
module.export = {
setupFilesAfterEnv: ['@incognitus/vuex-test-utils'],
}
```## Basic useage
```javascript
expect.action(actions.foobar).toCommitWithPayload('foo', 'bar')
```or
```javascript
expect.action(actions.fizzbuzz).toDispatchWithPayload('fizz', 'buzz')
```when checking order
```javascript
exect.action(actions.foofizz).toCommitInOrder('foobar', 'fizzbuzz')
```Things that can be checked are:
* toCommit
* toCommitWithPayload
* toCommitAsRoot
* toCommitInOrder
* toDispatch
* toDispatchWithPayload
* toDispatchAsRoot
* toDispatchInOrder## Passing action payload and contexts
Payload, state, root state, getters, and root getters can also be passed in with the option parameters on the `expect.action` method
```javascript
// Payload
expect.action(actions.foobar, {foo: bar})// Context
exect.action(actions.foobar, undefined, {state: {foo: 'bar'}, rootState: {version: '1.0.0'}, etc..})
```