我在使用 react-saga-test-plan 时遇到问题
I'm having trouble using react-saga-test-plan
以下代码是官方给出的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()
})
但结果实际上是错误的
error
以下是版本信息:
"redux-saga": "^1.0.0-beta.0",
"redux-saga-test-plan": "^3.7.0"
求助!!!
warning when install
我换了redux-saga的版本就正常了
所以,应该是redux-saga-test-plan不支持redux-saga beta版本
以下代码是官方给出的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()
})
但结果实际上是错误的
error
以下是版本信息:
"redux-saga": "^1.0.0-beta.0",
"redux-saga-test-plan": "^3.7.0"
求助!!!
warning when install
我换了redux-saga的版本就正常了
所以,应该是redux-saga-test-plan不支持redux-saga beta版本