我正在测试这个传奇
export function* foo() {
yield put(actions.start());
yield put(actions.bar({
onSuccess: () => {
// do something
},
onFailed: () => {
// do something else
}
}));
yield put(userActions.done());
}
Run Code Online (Sandbox Code Playgroud)
这是我的测试
it('should test foo saga, and put start, bar and done actions', () => {
// assertions / expect
testSaga(sagas.foo)
.next()
.put(actions.start())
.next()
.put(
actions.bar({
onSuccess: () => {},
onFailed: () => {},
}),
)
.next()
.put(actions.done())
.next()
.isDone();
});
Run Code Online (Sandbox Code Playgroud)
当我从 saga 中删除有效载荷并测试它通过时没有问题,但是当我添加有效载荷(不仅是 onSuccess 和 onFailed 回调的任何内容)时,它向我显示了这个错误
Assertion failed: put …Run Code Online (Sandbox Code Playgroud)