question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error running incrementAsync test

See original GitHub issue

I’ve copied the test content, and it fails when I run it:

incrementAsync Saga test

/srv/http/redux-saga-beginner-tutorial/sagas.spec.js:16 var gen = (0, _sagas.incrementAsync)(); ^

TypeError: (0 , _sagas.incrementAsync) is not a function at Test.<anonymous> (/srv/http/redux-saga-beginner-tutorial/sagas.spec.js:8:15) at Test.bound [as _cb] (/srv/http/redux-saga-beginner-tutorial/node_modules/tape/lib/test.js:64:32) at Test.run (/srv/http/redux-saga-beginner-tutorial/node_modules/tape/lib/test.js:83:10) at Test.bound [as run] (/srv/http/redux-saga-beginner-tutorial/node_modules/tape/lib/test.js:64:32) at Immediate.next (/srv/http/redux-saga-beginner-tutorial/node_modules/tape/lib/results.js:71:15) at runCallback (timers.js:756:18) at tryOnImmediate (timers.js:717:5) at processImmediate [as _immediateCallback] (timers.js:697:5)

Reason for that is that we are not exporting the function, like:

export function* incrementAsync()

See, the tutorial took ride of the export directive when it introduced rootSaga() concept.

https://redux-saga.js.org/docs/introduction/BeginnerTutorial.html

import { delay } from 'redux-saga'
import { put, takeEvery, all } from 'redux-saga/effects'


function* incrementAsync() {
  yield delay(1000)
  yield put({ type: 'INCREMENT' })
}


function* watchIncrementAsync() {
  yield takeEvery('INCREMENT_ASYNC', incrementAsync)
}


// notice how we now only export the rootSaga
// single entry point to start all Sagas at once
export default function* rootSaga() {
  yield all([
    helloSaga(),
    watchIncrementAsync()
  ])
}

So, if you guys wanna test the function, export it.

export function* incrementAsync() {
  yield delay(1000)
  yield put({ type: 'INCREMENT' })
}

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:17
  • Comments:5

github_iconTop GitHub Comments

2reactions
Shelley2014commented, Sep 19, 2021

I am already using yield call(delay, 1000); and also changed the functions to be exported but getting errors:

> redux-saga-beginner-tutorial@0.0.0 test
> babel-node sagas.spec.js | tap-spec


  incrementAsync Saga test

    redux-saga error: uncaught at check
    call: argument fn is undefined
C:\GIT\redux-saga-beginner-tutorial\src\node_modules\redux-saga\lib\internal\utils.js:45
    throw new Error(error);
    ^

Error: call: argument fn is undefined
    at check (C:\GIT\redux-saga-beginner-tutorial\src\node_modules\redux-saga\lib\internal\utils.js:45:11)
    at getFnCallDesc (C:\GIT\redux-saga-beginner-tutorial\src\node_modules\redux-saga\lib\internal\io.js:108:20)
    at call (C:\GIT\redux-saga-beginner-tutorial\src\node_modules\redux-saga\lib\internal\io.js:133:23)
    at Test.<anonymous> (C:/GIT/redux-saga-beginner-tutorial/src/sagas.spec.js:11:5)
    at Test.bound [as _cb] (C:\GIT\redux-saga-beginner-tutorial\src\node_modules\tape\lib\test.js:88:32)
    at Test.run (C:\GIT\redux-saga-beginner-tutorial\src\node_modules\tape\lib\test.js:105:10)
    at Test.bound [as run] (C:\GIT\redux-saga-beginner-tutorial\src\node_modules\tape\lib\test.js:88:32)
    at Immediate.next (C:\GIT\redux-saga-beginner-tutorial\src\node_modules\tape\lib\results.js:82:19)
    at processImmediate (internal/timers.js:461:21)

Please check if you export delay also.

2reactions
dgobaudcommented, Sep 24, 2018

i missed it initially too but on https://redux-saga.js.org/docs/introduction/BeginnerTutorial.html the code right after “Well, redux-saga provides a way to make the above statement possible. Instead of calling delay(1000) directly inside incrementAsync, we’ll call it indirectly:” that changes the delay invocation to using call also adds export to incrementAsync.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IncrementAsync is not saving - Scripting Support - DevForum
return test:IncrementAsync(tostring(userId), tonumber(saving)) end). I tried without pcall and the dev console error code said 502 etc.
Read more >
redux-saga - Bountysource
I've copied the test content, and it fails when I run it: incrementAsync Saga test. /srv/http/redux-saga-beginner-tutorial/sagas.spec.js:16
Read more >
Advanced Hooks - React Hooks Testing Library
Errors. If you need to test that a hook throws the errors you expect it to, you can use result.error to access an...
Read more >
How to atomic increment when row might not exist?
If you have multiple calls of IncrementAsync using the same key , there would be a problem since FindAsync looks for an existing...
Read more >
Read Me | redux-saga
They are like daemon tasks that run in the background and choose their own logic of progression. In the example above, incrementAsync pulls...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found