B
B
beefront172018-07-13 07:51:44
Software testing
beefront17, 2018-07-13 07:51:44

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);
  }

Project on react/redux, I use jest/enzyme for tests.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksei Podgaev, 2018-08-16
@alexiusp

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 question

Ask a Question

731 491 924 answers to any question