subblue / redux-mock-store

A mock store for your testing your redux async action creators and middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Circle CI

redux-mock-store

A mock store for your testing your redux async action creators and middleware

Install

npm install redux-mock-store --save-dev

How to use

// actions.test.js

import configureStore from 'redux-mock-store';

const middlewares = []; // add your middlewares like `redux-thunk`
const mockStore = configureStore(middlewares);

// Test in mocha
it('should dispatch action', (done) => {
  const getState = {}; // initial state of the store
  const action = { type: 'ADD_TODO' };
  const expectedActions = [action];

  const store = mockStore(getState, expectedActions, done);
  store.dispatch(action);
})

License

MIT

About

A mock store for your testing your redux async action creators and middleware

License:MIT License


Languages

Language:JavaScript 100.0%