title: Jest: fake setInterval not working as expected
body: <p>I'm trying to create a Timer component, that allows children to start a timer, and then provides them with how much time is left in 1 second intervals.</p>
  
  <p>I have the following test:</p>
  
  <p> <a href="https://github.com/NirBenita/todo-pomo/blob/test-timer/src/App.test.tsx#L82" rel="nofollow noreferrer">Full Code</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/* Test */
  jest.useFakeTimers()
  it.only('should update the reamining time every second', () =&gt; {
    const time = 1/12
    const wrapper = shallow(&lt;Timer time={time} /&gt;)
  
    wrapper.find('.start').simulate('click')
  
    jest.runAllTimers()    
  
    expect(setInterval.mock.calls.length).toBe(4)
  })</code></pre>
  </div>
  </div>
  </p>
  
  <p> <a href="https://github.com/NirBenita/todo-pomo/blob/test-timer/src/components/Timer.tsx#L29" rel="nofollow noreferrer">Full Code</a>
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/*    Code     */
  
  updateTimeLeft() {
    const now: number = +new Date()
    const timeLeft = this.state.endTime - now
  
    if (timeLeft &lt; 0) {
      clearInterval(this.state.timeInterval)
    }
    
    this.setState({ timeLeft })
  }
  
  intializeTimer(minutes: number) {
    const startTime: number = new Date().getTime()
    const endTime: number = new Date(startTime + minutes * 60 * 1000).getTime()
  
    this.setState({
      startTime,
      endTime
    })
  
    const timeInterval: NodeJS.Timer = global.setInterval(
      () =&gt; this.updateTimeLeft(),
      1000
    )
    this.setState({ timeInterval })
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>The code works. The problem is, in the test, <code>setInteval.mock.calls.length = 1</code>, not matter what.</p>
  
  <p>Is there anything I misunderstood about Jest fake timers?</p>
  
  <p>Thank you ❤️</p>