Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

A helper utility that makes available a mock redux store and Provider for the purposes of testing connected components.

License

Notifications You must be signed in to change notification settings

scalable-react/redux-mock-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redux Mock Provider

A simple utility to be used for testing React Redux applications.

Getting started

To install, run

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('<Header /> component', () => {
  const component = mount(
    <MockProvider store={store}>
      <Header />
    </MockProvider>
  );
  // ... tests go here.
});

About

A helper utility that makes available a mock redux store and Provider for the purposes of testing connected components.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published