@incognitus/vuex-test-utils
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Vuex-Test-Utils

Coverage Status
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
module.export = {
  setupFilesAfterEnv: ['@incognitus/vuex-test-utils'],
}

Basic useage

expect.action(actions.foobar).toCommitWithPayload('foo', 'bar')

or

expect.action(actions.fizzbuzz).toDispatchWithPayload('fizz', 'buzz')

when checking order

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

// Payload
expect.action(actions.foobar, {foo: bar})

// Context
exect.action(actions.foobar, undefined, {state: {foo: 'bar'}, rootState: {version: '1.0.0'}, etc..})

Readme

Keywords

Package Sidebar

Install

npm i @incognitus/vuex-test-utils

Weekly Downloads

0

Version

2.0.3

License

MIT

Unpacked Size

182 kB

Total Files

12

Last publish

Collaborators

  • incognitus-admin
  • stummej