Introduction
Deprecated
This repositiory is deprecated and will not be maintained. It will soon be archived.
enzyme-context
Enzyme Context is a pluggable library which simplifies the process of testing components that rely on react context.
Basic Usage
test-utils/enzyme.ts
import { createMount, createShallow } from 'enzyme-context';
import { reduxContext } from 'enzyme-context-redux';
import { routerContext } from 'enzyme-context-react-router-4';
import { createStore } from 'redux';
import reducer from './reducer'; // this is _your_ app's main reducer
const plugins = {
store: reduxContext({
createStore: () => createStore(reducer),
}),
history: routerContext(),
};
export const mount = createMount(plugins);
export const shallow = createShallow(plugins);MyComponent.spec.tsx
Official Plugins
Enzyme Context maintains a few official plugins for some popular react libraries:
Last updated
Was this helpful?