title: Test millisecods argument on setTimeout with jest
body: <p>I have a method to trigger a pause using a promise with a setTimeout:</p>
  <pre><code>pause = ({ time } = {}) =&gt; {
    const pauseTime = time || 500;
  
    return new Promise((resolve) =&gt; {
      setTimeout(() =&gt; {
        resolve()
      }, pauseTime)
    })
  }
  </code></pre>
  <p>I want to test it with jest, expecting the timeout function gets the time argument that pause method receives.</p>
  <pre><code>jest.useFakeTimers();
  
  const setTimeoutSpy = spyOn(window, 'setTimeout')
  const pausePromise = pause({ time: 2500 })
  
  
  await jest.runAllTimers();
  
  pausePromise.then(() =&gt; {
    expect(setTimeoutSpy).toHaveBeenCalledTimes(1);
    expect(setTimeoutSpy).toHaveBeenCalledWith(2500);
  })
  
  jest.useRealTimers();
  return pausePromise
  </code></pre>
  <p>I tried with mocks and spies. Also tried without timers and awaiting the promise. But I always get the same result: <em><strong>Expected spy to have been called one time, but it was called zero times.</strong></em></p>
  <p>Any idea?</p>
  <p>Thanks!</p>