# redux-test-utils

> Test utils to simplify mocking for redux.

Latest version **1.0.2** (published 2020-12-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-test-utils
pnpm add redux-test-utils
yarn add redux-test-utils
bun add redux-test-utils
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-12-18 |
| First published | 2016-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Dennis Axelsson |
| Maintainers | knegusen |
| Keywords | dispatch, redux, store, test |

## Links

- npm: https://www.npmjs.com/package/redux-test-utils
- Repository: https://github.com/Knegusen/redux-test-utils
- npm.io page: https://npm.io/package/redux-test-utils

## Dependencies (1)

- [fast-deep-equal](https://npm.io/package/fast-deep-equal.md) ^2.0.1

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-12-18
- 1.0.1 — 2020-12-18
- 1.0.0 — 2020-04-15
- 0.3.0 — 2018-10-01
- 0.2.2 — 2017-11-28
- 0.2.1 — 2017-11-09
- 0.2.0 — 2017-11-09
- 0.1.3 — 2017-09-28
- 0.1.2 — 2017-01-17
- 0.1.1 — 2016-07-14
- 0.1.0 — 2016-07-14

## README

# redux-test-utils [![Build Status](https://travis-ci.org/knegusen/redux-test-utils.svg?branch=master)](https://travis-ci.org/knegusen/redux-test-utils)

Test utils to simplify testing of containers in redux.

## Install

In the terminal execute the following command:

```
$ npm install redux-test-utils --save-dev
```

## How to use

### createMockStore

```js

import { createMockStore } from 'redux-test-utils';

describe('example', () => {
  it('works', () => {
    const state = 'state';
    const store = createMockStore(state);
    const action = {
      type: 'type',
      data: 'data'
    };
    store.dispatch(action);
    
    expect(store.getAction(action.type)).toEqual(action);
    expect(store.getActions()).toEqual([action]);
    expect(store.isActionDispatched(action)).toBe(true);
    expect(store.isActionTypeDispatched(action.type)).toBe(true);
    expect(store.getState()).toBe(state);
  });
});

```

### createMockDispatch

```js

import { createMockDispatch } from 'redux-test-utils';

describe('example', () => {
  it('works', () => {
    const state = 'state';
    const dispatchMock = createMockDispatch();
    const action = {
      type: 'type',
      data: 'data',
    };
    dispatchMock.dispatch(action);

    expect(dispatchMock.getAction(action.type)).toEqual(action);
    expect(dispatchMock.getActions()).toEqual([action]);
    expect(dispatchMock.isActionDispatched(action)).toBe(true);
    expect(dispatchMock.isActionTypeDispatched(action.type)).toBe(true);
  });
});

```

---
_Source: https://npm.io/package/redux-test-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
