redux-saga-test-plan run的时候报错

如下,是官方提供的一个demo

import { call, put, take } from 'redux-saga/effects'
import { expectSaga } from 'redux-saga-test-plan'

function * userSaga (api) {
  const action = yield take('REQUEST_USER')
  const user = yield call(api.fetchUser, action.payload)

  yield put({ type: 'RECEIVE_USER', payload: user })
}

it('just works!', () => {
  const api = {
    fetchUser: id => ({ id, name: 'Tucker' })
  }

  return expectSaga(userSaga, api)
    // Assert that the `put` will eventually happen.
    .put({
      type: 'RECEIVE_USER',
      payload: { id: 42, name: 'Tucker' }
    })

    // Dispatch any actions that the saga will `take`.
    .dispatch({ type: 'REQUEST_USER', payload: 42 })

    // Start the test. Returns a Promise.
    .run()
})

结果猝不及防的报错了。

run的时候报错了

版本:

    "redux-saga": "^1.0.0-beta.0",
    "redux-saga-test-plan": "^3.7.0"

有用过的大佬吗。。。

阅读 2.1k
1 个回答

clipboard.png
看了下,应该是redux-saga-test-plan对redux-saga的beta版本还不支持的原因吧。
我换了16.2版本的saga就可以跑了。

推荐问题