我正在使用redux-mock-store用玩笑和酵素来测试我的应用程序。我通过调用商店来安装我的组件:
const mockStore = configureStore([thunk]);
我已经在使用thunk
。现在,我要测试的代码编写如下:
//from my component
const someFunc = async ({arg1, arg2...}) => {
await dispatch(setWithSomePromise({arg1, arg2}));
// setWithSomePromise is a promise
}
//in my actions file, I've done
const setWithSomePromise = ({arg1, arg2}) => async dispatch => {
const someOtherPromiseResp = await(someOtherPromise);
dispatch({
type: 'MY_ACTION',
payload: someOtherPromiseResp,
});
return someOtherPromiseResp;
}
现在,只要我的代码到达setWithSomePromise
,就会向我抛出此错误:
Error: Actions may not have an undefined "type" property. Have you misspelled a constant? Action: {}
我知道这是因为它无法找到操作,但是我不知道如何解决该问题?