Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

take assertion with redux-saga-test-plan that takes a function as pattern gives 'take effects do not match' error #355

Open
lolero opened this issue Aug 21, 2020 · 0 comments

Comments

@lolero
Copy link

lolero commented Aug 21, 2020

I want to test a saga that yields a take effect which takes a function as pattern, e.g.

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?

@lolero lolero changed the title How can I assert a take effect that takes a function as pattern take assertion with redux-saga-test-plan that takes a function as pattern gives 'take effects do not match' error Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant