I’m trying to test a saga using redux-saga-test-plan, but faced a problem of passing an anonymous function as an argument in the “call” effect.
I know that a possible solution could be to name this () => {} function and to import it to my spec.js file, but would it be a good practice of calling it like “emptyFunction”? Is there some way to just mock it instead of naming and exporting?
Here is my saga:
`export function* sagaToTest() {
yield call(foo, () => {});
}`
And a test in spec.js file
`it('sagaToTest', () => {
testSaga(Saga.sagaToTest)
.next()
.call(foo, () => {})
.next()
.isDone();
});`
The error I get:
`SagaTestError:
Assertion 1 failed: call effects do not match
Expected
{ ‘@@redux-saga/IO’: true,
combinator: false,
type: ‘CALL’,
payload: { context: null, fn: [Function: foo], args: [ [Function] ] } }
Actual
{ ‘@@redux-saga/IO’: true,
combinator: false,
type: ‘CALL’,
payload: { context: null, fn: [Function: foo], args: [ [Function] ] } }`
hypnotie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.