Answer the question
In order to leave comments, you need to log in
How to test setTimeOut, jest/enzyme?
Good afternoon! Please tell me how to test this code, namely setTimeOut
componentDidMount() {
const { doAction} = this.props;
setTimeout(() => doAction('do'), 1000);
}
Answer the question
In order to leave comments, you need to log in
Everything is described here:
https://jestjs.io/docs/en/timer-mocks
set up mocks, then call jest.runAllTimers(); and see if the mok volunteered
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question