根据本文https://medium.com/@antonybudianto/react-router-testing-with-jest-and-enzyme-17294fefd303,我是tryint来测试URL加载。我得到的错误是Invariant Violation: Could not find "store" in either the context or props of "Connect(Header)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(Header)".
import App from '../../src/App';
const jQuery = require('jquery');
window.jQuery = window.$ = jQuery;
import configureStore from 'redux-mock-store';
import promise from 'redux-promise';
const modals = {confirmTitle: ''};
//create any initial state needed
const initialState = { user: { activeUser: {id:1} } , modals };
// here it is possible to pass in any middleware if needed into //configureStore
const middlewares = [promise]
const mockStore = configureStore(middlewares);
const mockedCallback = () => Promise.resolve([]);
describe('React Router paths', () => {
test('AuditSoxApproval path should not redirect to 404', () => {
let store = mockStore(initialState)
const wrapper = mount(
<MemoryRouter initialEntries={[ '/audit/soxapprovedcomms' ]}>
<App store={store} modals = {modals} />
</MemoryRouter>
) ;
expect(wrapper.find(AuditSoxApproval)).toHaveLength(1);
});...