The following code is a demo given by the official
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()
})
But the result is actually an error.
The following is the version information:
"redux-saga": "^1.0.0-beta.0",
"redux-saga-test-plan": "^3.7.0"
Help!!!
I changed the version of redux-saga and it was normal.
So, it should be redux-saga-test-plan does not support the beta version of redux-saga.