redux-testing-library
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

redux-testing-library

Simple and maintainable tests for your react/redux application inspired by react-testing-library.

Build Status Coverage Status code style: prettier License: MIT

Features

  • simple data-driven integration tests
  • dispatch actions, wait for store changes and assert the result
  • do not test implementation details: just rely on your actions and selectors
  • it also covers all middleware functionalities, e.g. async code via redux-saga
  • includes the full power of react-testing-library (no other dependencies)

How to use?

import * as React from "react";
import { render } from "redux-testing-library";
 
import { TodoApp, TodoActions, TodoSelectors } from "./example";
 
describe("when addTodo action is dispatched", () => {
  it("adds todo item to the store", async () => {
    const { store, waitForStoreChange } = render(<TodoApp.UI />, TodoApp.store);
 
    store.dispatch(TodoActions.addTodo("Test your application"));
 
    await waitForStoreChange(state => {
      const todos = TodoSelectors.getTodos(state);
      expect(todos[0].text).toBe("Test your application");
    });
  });
});

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.21latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.21
2.0.10
2.0.00
1.1.01
1.0.00

Package Sidebar

Install

npm i redux-testing-library

Weekly Downloads

1

Version

2.0.2

License

MIT

Unpacked Size

6.85 MB

Total Files

16

Last publish

Collaborators

  • jabro86