admin管理员组文章数量:1401827
I am trying to test a Redux-Saga using redux-saga-test-plan, but I keep getting the error:
runSaga(options, saga, ...args): saga argument must be a Generator function!
Here is my saga:
export function* watchLayoutFlow(): SagaIterator {
yield takeEvery(actionTypes.CHANGE_INTERFACE_SETTINGS, changeInterfaceSettings);
yield takeEvery(actionTypes.OPEN_MAP, openMap);
yield takeEvery(actionTypes.OPEN_WORK_AREA, openWorkArea);
}
export function* rootSaga(): SagaIterator {
yield fork(watchLayoutFlow);
}
And my test:
import { expectSaga } from 'redux-saga-test-plan';
import { OPEN_MAP } from '../../../actions/ActionTypes';
import { watchLayoutFlow } from '../../../sagas/Sagas';
describe('Call flow tests', () => {
it('Should execute takeEvery for OPEN_GMAP', () => {
return expectSaga(watchLayoutFlow).take(OPEN_MAP).run();
});
});
What I have tried
The application runs fine, but the test fails with the above error.
I checked that watchLayoutFlow is correctly exported as a generator function.
I confirmed that redux-saga-test-plan is correctly installed.
Dependencies
"react": "^18.2.0"
"react-redux": "^9.2.0"
"redux": "^5.0.1"
"redux-saga": "1.3.0"
"redux-saga-test-plan": "4.0.6"
"jest": "26.6.3"
What could be causing this error?
本文标签:
版权声明:本文标题:redux - Why does expectSaga(watchLayoutFlow).take(OPEN_MAP).run(); throw "saga argument must be a Generator function!&a 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744254920a2597431.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论