A helper utility that makes available a mock redux store and Provider for the purposes of testing connected components.
npm install redux-mock-providerA simple utility to be used for testing React Redux applications.
npm install --save-dev redux-mock-provider
`Usage
To use the provider in your testing utils, simple import it. You can either pass your own store to the component, of you can also use the getMockStore helper function, passing in the initialState from your reducer, plus a key that corresponds to the reducer's name.`
import React from 'react';
import { mount } from 'enzyme';
import { expect } from 'chai';
import { Header } from 'components';
import { initialState } from 'components/Auth/reducer';import MockProvider, { getMockStore } from 'redux-mock-provider';
const store = getMockStore({
key: 'auth',
state: initialState
});
describe(' component', () => {
const component = mount(
);
// ... tests go here.
});
``