title: How to reset Jest mock functions calls count before every test
body: <p>I'm new to Jest, I'm trying to use it for testing if a function was called or not. I noticed the mock.calls.length is not resetting for every test but accumulating. How can I make it 0 before every test? I don't want my next tests depends on the results of the previous.</p>
  
  <p>I know there is beforeEach in Jest - should I use it? What is the best way to reset mock.calls.length? Thank you. </p>
  
  <p>A code example:</p>
  
  <p>Sum.js:</p>
  
  <pre><code>import local from 'api/local';
  
  export default {
    addNumbers(a, b) {
      if (a + b &lt;= 10) {
        local.getData();
      }
      return a + b;
    },
  };
  </code></pre>
  
  <p>Sum.test.js</p>
  
  <pre><code>import sum from 'api/sum';
  import local from 'api/local';
  jest.mock('api/local');
  
  // For current implementation, there is a difference 
  // if I put test 1 before test 2. I want it to be no difference
  
  // test 1
  test('should not to call local if sum is more than 10', () =&gt; {
    expect(sum.addNumbers(5, 10)).toBe(15);
    expect(local.getData.mock.calls.length).toBe(0);
  });
  
  // test 2
  test('should call local if sum &lt;= 10', () =&gt; {
    expect(sum.addNumbers(1, 4)).toBe(5);
    expect(local.getData.mock.calls.length).toBe(1);
  });
  </code></pre>