jest-redux
Jest matchers for testing redux easier and more declaritive.
Table of Contents
Getting start
Installation
yarn add --dev jest-redux
or
npm install --save-dev jest-redux
Setup
Via setupTestFrameworkScriptFile
config
Add jest-redux
to your Jest setupTestFrameworkScriptFile
configuration
"jest": {
"setupTestFrameworkScriptFile": "jest-redux"
}
Via setupTest
script
Require jest-redux
from setupTest script
require('jest-redux');
Then add this config
"jest": {
"setupTestFrameworkScriptFile": "./setupTest.js"
}
API Reference
toHandleActions(reducer, actionCreators)
Checks reducer to handle given actionCreators.
Example
expect(reducer).toHandleActions(actions);
toHaveInitialState(reducer, initialState)
Checks reducer against given intitialState.
Example
expect(reducer).toHaveInitialState(initialState);
Checks given action creators to match with previous snapshot.
Example
expect(actionCreators).toMatchActionCreatorsSnapshot();
License
MIT