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

执行npm run test时报错:Error: call: argument fn is undefined or null #66

Open
zl-fire opened this issue Apr 4, 2020 · 1 comment

Comments

@zl-fire
Copy link

zl-fire commented Apr 4, 2020

执行npm run test时报错:Error: call: argument fn is undefined or null

image

如下修改代码就正常了

image

import test from 'tape';

// import { delay } from 'redux-saga'
import { put, call , delay} from 'redux-saga/effects'
import { incrementAsync } from './sagas'

test('incrementAsync Saga test', (t) => {
  const generator = incrementAsync()

  t.deepEqual(
    generator.next().value,
    // call(delay, 1000),
    delay(1000),
    'counter Saga must call delay(1000)'
  )

  t.deepEqual(
    generator.next().value,
    put({type: 'INCREMENT'}),
    'counter Saga must dispatch an INCREMENT action'
  )

  t.deepEqual(
    generator.next(),
    { done: true, value: undefined },
    'counter Saga must be done'
  )

  t.end()
});
@jagretz
Copy link

jagretz commented Apr 10, 2020

You shouldn't need to import delay from redux-saga/effects. Instead, make sure you are adding the export keyword before the "delay" defined in the sagas.js file. eg

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

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

2 participants