@jest-matchers/redux
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

@jest-matchers/redux

coverage build npm version

Jest matchers for redux.

Installing

Using npm

npm install @jest-matchers/redux

Using yarn

yarn add @jest-matchers/redux

Getting started

To get started with @jest-matchers/redux you need to import it before your tests are ran. This can be done in a setupTestFrameworkScriptFile or setupFiles file.

setupTests.js
require("@jest-matchers/redux");

Usage

expect(mockStore).toHaveDispatched(action);

This function can be used to test whether an action has been dispatched by a (mock) store.

expect(store).toHaveDispatched("SOME_ACTION");
expect(store).toHaveDispatched({type: "SOME_ACTION"});

expect(action).toHaveBeenDispatchedBy(mockStore)

This function can be used to test whether an action has been dispatched by a (mock) store.

expect("SOME_ACTION").toHaveBeenDispatchedBy(store);
expect({type: "SOME_ACTION"}).toHaveBeenDispatchedBy(store);

expect(mockStore).toReduceActionToState(action, state)

This function can be used to test if an action is reduced correctly.

expect(mockStore).toReduceActionToState("SOME_ACTION", "SOME_STATE");
expect(mockStore).toReduceActionToState({type: "SOME_ACTION"}, "SOME_STATE");

Contributing

Contributions in the form of pull requests and bug reports are appreciated.

Running tests

Tests are ran using the test npm script.

Using npm

npm test

Using yarn

yarn test

Package Sidebar

Install

npm i @jest-matchers/redux

Weekly Downloads

3

Version

0.0.2

License

ISC

Unpacked Size

1.15 MB

Total Files

29

Last publish

Collaborators

  • jewetnitg