Writing Unit Tests with Jest
What Jest feature enables testing time-dependent code?
jest.useFakeTimers();
test('delayed operation', () => {
const callback = jest.fn();
setTimeout(callback, 1000);
jest.runAllTimers();
expect(callback).toHaveBeenCalled();
});