jfairbank / redux-saga-test-plan

Test Redux Saga with an easy plan.
http://redux-saga-test-plan.jeremyfairbank.com
MIT License
1.25k stars 127 forks source link

Cannot read property 'toPromise' of undefined #353

Open timB73 opened 4 years ago

timB73 commented 4 years ago

I am using redux-saga version 1.1.3 and version 4.0.0-rc.3 of redux-saga-test-plan. Are these not compatible with each other? I ran the example test and I get the following error: "TypeError: Cannot read property 'toPromise' of undefined" which happens at the run() method.

at taskPromise (node_modules/redux-saga-test-plan/lib/expectSaga/index.js:590:17)
at start (node_modules/redux-saga-test-plan/lib/expectSaga/index.js:601:23) at Object.run (node_modules/redux-saga-test-plan/lib/expectSaga/index.js:646:5)

timB73 commented 4 years ago

I seem to get the same error with version 1.1.1 of redux-saga and 4.0.0-rc.2 of redux-saga-test-plan

jp928 commented 4 years ago

@timB73 do you have sample to reproduce this?

timB73 commented 4 years ago

Actually it looks like it might not be to do with redux-saga-test-plan as I got the same error trying to create my own helper function based on redux-saga docs... very confused 🤔

import { runSaga } from 'redux-saga';

export async function recordSaga(saga, initialAction, initialState) {
  const dispatched = [];

  await runSaga(
    {
      dispatch: action => dispatched.push(action),
      getState: () => initialState
    },
    saga,
    initialAction
  ).toPromise();

  return dispatched;
}

It gives error cannot read 'toPromise' of undefined when I call runSaga with a basic generator function. I can't find anything about this anywhere so must be something to do with my setup ??

jakobdamjensen commented 3 years ago

I am experiencing the same problem here with code very similar to yours @timB73 . Did you find a solution?

timB73 commented 3 years ago

I am experiencing the same problem here with code very similar to yours @timB73 . Did you find a solution?

Unfortunately I didn't :(