我正在尝试测试我的组件,但由于商店我有一个错误。
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)
});
});
错误是:
不变违规:在“Connect(withRouter(DropzoneComponent))”的上下文或道具中找不到“store”。要么将根组件包装在 a 中,要么将“store”作为道具显式传递给“Connect(withRouter(DropzoneComponent))”。