redux-saga-test-plan icon indicating copy to clipboard operation
redux-saga-test-plan copied to clipboard

all effects do not match (but they do?)

Open cjones26 opened this issue 6 years ago • 1 comments

Hi, I'm having an issue attempting to test one of my "root" sagas which looks like so:

export function* rootSaga() {
  yield all([
    activeRootSaga(),
    inactiveRootSaga(),
    takeLatest(DELETE_ONBOARD, deleteOnboardSaga),
    takeLatest(ADD_ONBOARD, addOnboardSaga)
  ]);
}

I am able to properly test this saga without utilizing redux-saga-test-plan like so:

  describe('rootSaga tests', () => {
    it('should trigger all action listeners', () => {
      const iterator = rootSaga();
      const expectedYield = all([
        activeRootSaga(),
        inactiveRootSaga(),
        takeLatest(DELETE_ONBOARD, deleteOnboardSaga),
        takeLatest(ADD_ONBOARD, addOnboardSaga)
      ]);

      expect(iterator.next().value).toEqual(expectedYield);
    });
  });

Unfortunately, when attempting to test the saga utilizing redux-saga-test-plan, like so:

  describe('rootSaga tests', () => {
    it('should trigger all action listeners', () => {
      testSaga(rootSaga)
        .next()
        .all([
          activeRootSaga(),
          inactiveRootSaga(),
          takeLatest(DELETE_ONBOARD, deleteOnboardSaga),
          takeLatest(ADD_ONBOARD, addOnboardSaga)
        ])
        .next()
        .isDone();
    });
  });

I receive the following error:

● onboardSagas tests › rootSaga tests › should trigger all action listeners

SagaTestError:
Assertion 1 failed: all effects do not match

Expected
--------
[ {},
  {},
  { '@@redux-saga/IO': true,
    FORK:
     { context: null,
       fn: [Function: takeLatest],
       args:
        [ 'ruleManagement/DELETE_ONBOARD',
          [Function: deleteOnboardSaga] ] } },
  { '@@redux-saga/IO': true,
    FORK:
     { context: null,
       fn: [Function: takeLatest],
       args:
        [ 'ruleManagement/ADD_ONBOARD',
          [Function: addOnboardSaga] ] } } ]

Actual
------
[ {},
  {},
  { '@@redux-saga/IO': true,
    FORK:
     { context: null,
       fn: [Function: takeLatest],
       args:
        [ 'ruleManagement/DELETE_ONBOARD',
          [Function: deleteOnboardSaga] ] } },
  { '@@redux-saga/IO': true,
    FORK:
     { context: null,
       fn: [Function: takeLatest],
       args:
        [ 'ruleManagement/ADD_ONBOARD',
          [Function: addOnboardSaga] ] } } ]

  56 |       testSaga(rootSaga)
  57 |         .next()
> 58 |         .all([
     |          ^
  59 |           activeRootSaga(),
  60 |           inactiveRootSaga(),
  61 |           takeLatest(DELETE_ONBOARD, deleteOnboardSaga),

  at new SagaTestError (node_modules/redux-saga-test-plan/lib/shared/SagaTestError.js:17:57)
  at assertSameEffect (node_modules/redux-saga-test-plan/lib/testSaga/assertSameEffect.js:20:11)
  at Object.all (node_modules/redux-saga-test-plan/lib/testSaga/index.js:71:40)
  at Object.all (src/state-management/modules/ruleManagement/__tests__/onboardSagas.test.js:58:10)

cjones26 avatar Feb 25 '19 15:02 cjones26

Same issue here

marcosdeseul avatar Nov 17 '19 20:11 marcosdeseul