Redux-mock-store给出错误,表明操作可能没有未定义的“ type”属性。你拼错了常量吗?

时间:2018-07-23 09:34:15

标签: reactjs jestjs redux-mock-store

我正在使用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: {}

我知道这是因为它无法找到操作,但是我不知道如何解决该问题?

0 个答案:

没有答案