import { mount } from'../test-utils/enzyme'; // import from the module defined aboveimport MyComponent from'./MyComponent';// this example uses jest, but that isn't required!describe('MyComponent', () => {let component;let store;let history;beforeEach(() => {// mount() returns an object with the mounted EnzymeWrapper component and each of the specified plugins.// In this example, it returns:// - component: the mounted EnzymeWrapper// - store: provided by the reduxContext plugin, a redux store// - history: provided by the routerContext plugin, a history object for URL manipulation ({ component, store, history } =mount(<MyComponent />)); });it('responds to redux state changes', () => {store.dispatch({ type:'SOME_ACTION' });component.update();expect(component.text()).toBe('...'); });it('responds to location changes', () => {history.push('/my/new/url');component.update();expect(component.text()).toBe('...'); });});
Official Plugins
Enzyme Context maintains a few official plugins for some popular react libraries: