vendredi 24 août 2018

Test component with a store Mocha and Enzyme

I am trying to test my component but because of the store I have an error.

import React from 'react';
import { shallow, simulate } from 'enzyme';
import configureStore from 'redux-mock-store';
import { Provider } from "react-redux";

import DropzoneComponent from '../components/DropzoneComponent';

const mockStore = configureStore();
const store = mockStore({});


describe('Dropzone component live test', () => {
    it('renders the component', () => {
      const wrapper = shallow(
        <Provider store = {store}>
          <DropzoneComponent />
        </Provider>).dive();
      expect(wrapper.exists()).to.equal(true)
    });
});

The error is :

Invariant Violation: Could not find "store" in either the context or props of "Connect(withRouter(DropzoneComponent))". Either wrap the root component in a , or explicitly pass "store" as a prop to "Connect(withRouter(DropzoneComponent))".

Aucun commentaire:

Enregistrer un commentaire