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?