我的反应组件中有这个
console.log(await store.dispatch(getAndSaveImages()));
我的测试是:
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
it("should call redux store...", () => {
const store = mockStore({ auth: { isAuth: true } })
store.dispatch = jest.fn(() => Promise.resolve("its working"));
component = mount(<Provider store={store}><User history={mockedHistory}/></Provider>);
});
问题是它没有模拟调度功能。