首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我在使用反应测试计划时遇到了麻烦

我在使用反应测试计划时遇到了麻烦
EN

Stack Overflow用户
提问于 2018-10-19 03:18:38
回答 1查看 201关注 0票数 0

下面的代码是官方提供的演示

代码语言:javascript
复制
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()
})

但其结果实际上是一个错误。

错误

以下是版本信息:

代码语言:javascript
复制
"redux-saga": "^1.0.0-beta.0",
"redux-saga-test-plan": "^3.7.0"

救命!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-19 07:26:10

安装时警告

我改变了redux-saga的版本,这很正常。

因此,它应该是redux-saga测试计划不支持测试版的redux-saga。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52885419

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档