Problem
In redux-saga
, I am using yield delay(1000);
.
During my unit test, I do expect(generator.next().value).toEqual(delay(1000));
.
I expect the test to pass.
This is my sagas.js
:
import { delay } from 'redux-saga';
export function* incrementAsync() {
yield delay(1000);
}
This is my sagas.test.js
import { delay } from 'redux-saga';
import { incrementAsync } from '../sagas';
describe('incrementAsync Saga test', () => {
it('should incrementAsync', () => {
const generator = incrementAsync();
expect(generator.next().value).toEqual(delay(1000));
});
});
● incrementAsync Saga test › should incrementAsync
expect(received).toEqual(expected)
Expected value to equal:
{"@@redux-saga/CANCEL_PROMISE": [Function anonymous]}
Received:
{"@@redux-saga/CANCEL_PROMISE": [Function anonymous]}
Difference:
Compared values have no visual difference.
question
How can I test redux-saga delay ?
instead of writing 'yield call(delay, 600)' where delay is an effect from 'redux-saga/effects' you should write 'yield delay(600)'
– Laird