redux-saga-beginner-tutorial icon indicating copy to clipboard operation
redux-saga-beginner-tutorial copied to clipboard

error in test

Open iLeonelPerea opened this issue 9 years ago • 5 comments

error in the following test:

assert.deepEqual( gen.next().value, call(delay, 1000), 'incrementAsync Saga must call delay(1000)' )

this gen.next().value return a promise as value:

{ value: Promise { _c: [], _a: undefined, _s: 0, _d: false, _v: undefined, _h: 0, _n: false, '@@redux-saga/cancelPromise': [Function] }, done: false }

So the test fail

iLeonelPerea avatar Jun 15 '16 20:06 iLeonelPerea

Getting the same error.

redux-saga error: uncaught at check call: argument [object Promise] is not a function /redux-saga-beginner-tutorial/node_modules/regenerator-runtime/runtime.js:537 throw exception;

This is disappointing :(

greg-murray-volusion avatar Dec 09 '16 23:12 greg-murray-volusion

For newcomers: I was getting the same error and the problem was on the first line of incrementAsync(): yield call(delay(1000)) should be yield call(delay, 1000)

rodolfoag avatar Apr 30 '17 16:04 rodolfoag

Thanks rodolfoag. Did you want to put in a pull request for your fix? Thanks

greg-murray-volusion avatar May 01 '17 13:05 greg-murray-volusion

It still happens with me, even with the call(delay, 1000) instead of delay(1000) - in both places, btw.

Here is the error:

image

Note how expected and actual are exactly the same, at least by character to character visual inspection.

ropinheiro avatar Jul 08 '20 16:07 ropinheiro

Meanwhile, I found this answer in StackOverflow:

https://stackoverflow.com/questions/49263089/how-to-test-redux-saga-delay

More specifically:

image

I suspected that something like that would be happening.

I fixed my problem by using this in both files (sagas.js and sagas.spec.js):

import { delay } from 'redux-saga'

instead of this:

const delay = ms => new Promise(res => setTimeout(res, ms))

I think the tutorial should be changed for this, too, as it not only fixes the issue, but also applies a bit of DRY philosophy to the code (not to mention the DRTW).

ropinheiro avatar Jul 08 '20 17:07 ropinheiro