Я тестирую эту сагу
export function* foo() {
yield put(actions.start());
yield put(actions.bar({
onSuccess: () => {
// do something
},
onFailed: () => {
// do something else
}
}));
yield put(userActions.done());
}
и вот мой тест
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();
});
, когда я удаляю полезную нагрузку из саги и тестирую, она проходит без проблем, но когда я добавляюполезная нагрузка (что угодно, не только обратные вызовы onSuccess и onFailed), она показывает мне эту ошибку
Assertion failed: put effects do not match
Expected
--------
{
channel: null,
action:
{ type: 'BAR',
payload:
{
onSuccess: [Function: onSuccess],
onFailed: [Function: onFailed]
}
}
}
Actual
------
{
channel: null,
action:
{ type: 'BAR',
payload:
{
onSuccess: [Function: onSuccess],
onFailed: [Function: onFailed]
}
}
}
Интересно, что фактическая и ожидаемая полезная нагрузка равны, но тест не проходит!