假设一个在有效载荷上运行的传奇,其中 action 已经过了 takeLatest 例如
action
takeLatest
export function* mySaga(action) { try { yield all(action.payload.items.map(p => call(doSomething, p))); } yield put(actionSuccess()); } catch (error) { yield put(actionFailed(error)); } } export function* watchMySaga() { yield takeLatest(AN_ACTION, mySaga); }
我怎么嘲笑 行动 在我的 redux-saga-test-plan 测试 mySaga ?AS action.payload 是 undefined ,我的测试当前引发错误。
行动
redux-saga-test-plan
mySaga
action.payload
undefined
所以看起来,您只需将一个模拟动作对象作为第二个参数传递给 expectSaga ,例如
expectSaga
return expectSaga(mySaga, action) .provide([[...]]) .put(actionSuccess()) .run();