Open lolero opened 4 years ago
I want to test a saga that yields a take effect which takes a function as pattern, e.g.
take
export function* mySaga(myAction: { type: string; }): Generator<TakeEffect, boolean, { type: string }> { const { type: actionType } = (yield take( (action: any) => action.type === myAction.type, )) as { type: string }; return actionType === myAction.type; }
with a test that looks like:
it('Should test mySaga', () => { testSaga(mySaga, { type: 'myActionType' }).next().take().next().finish(); });
but I get the following error:
SagaTestError: Assertion 1 failed: take effects do not match Expected -------- { '@@redux-saga/IO': true, combinator: false, type: 'TAKE', payload: { pattern: '*' } } Actual ------ { '@@redux-saga/IO': true, combinator: false, type: 'TAKE', payload: { pattern: [Function] } }
I have not been able to find how to assert the a take effect that takes a function pattern instead of a string. Can someone please help me?
I want to test a saga that yields a
take
effect which takes a function as pattern, e.g.with a test that looks like:
but I get the following error:
I have not been able to find how to assert the a take effect that takes a function pattern instead of a string. Can someone please help me?