title: Why Is My Jest Function Mock Affecting Another Test
body: <p>I have the test cases :</p>
  
  <pre><code>import { loginPagePresenter } from './LoginPagePresenter'
  import { apiGateway } from 'config/gatewayConfig'
  import { authRepository } from './AuthRepository'
  
  it('should update the auth repository user with the token, email and set authenticated observable when successesful api call', async () =&gt; {
    const authenticatedStub = {
      'success': true,
      'message': 'successful login',
      'email': 'a@b.com',
      'token': '123'
    }
  
    apiGateway.post = jest.fn().mockResolvedValue(authenticatedStub)
  
    loginPagePresenter.email = 'a@b.com'
    loginPagePresenter.password = 'aaabbbcom'
    await loginPagePresenter.submit()
    expect(authRepository.user.token).toBe('123')
    expect(authRepository.user.email).toBe('a@b.com')
    expect(authRepository.authenticated).toBe(true)
  })
  
  it('should not update the user model when NOT successesful api call', async () =&gt; {
  
    const notAutenticatedStub = {
      'success': false,
      'message': 'bad login',
      'email': '',
      'token': ''
    }
  
    apiGateway.post = jest.fn().mockResolvedValue(notAutenticatedStub)
  
    loginPagePresenter.email = 'a@b.com'
    loginPagePresenter.password = 'aaabbbcom'
    await loginPagePresenter.submit()
    expect(authRepository.user.token).toBe(null)
    expect(authRepository.user.email).toBe(null)
    expect(authRepository.authenticated).toEqual(false)
  })
  </code></pre>
  
  <p>The first test is affecting the second test. In other words if I comment out the first test then the second test works. I have checked the production code <strong>it works</strong> fine. But the mocking function of the first is having a side effect on the second (it looks like I can't reset the returned resolved function).</p>
  
  <p>Can somebody explain how to fix this?</p>