title: How to test the then part after promise in jest
body: <p>I'm working on a React project and I'm using jest to write tests for my code. </p>
  
  <p>This is the code I want to test. </p>
  
  <pre><code>const handleSubmit = (handleSuccess, handleErrors) =&gt; {
    signupAPI(user)
      .then(handleSuccess)
      .catch(handleErrors);
  };
  </code></pre>
  
  <p>Here's the test code:</p>
  
  <pre><code>test('should call handleSuccess', () =&gt; {
    signupAPI.mockImplementation((user) =&gt; Promise.resolve(user));
    const handleSuccess = jest.fn();
    const handleErrors = jest.fn();
  
    handleSubmit(handleSuccess, handleErrors); 
  
    expect(signupAPI).toHaveBeenCalled(); // test passes
  
    expect(handleSuccess).toHaveBeenCalled(); // test fails
  });
  </code></pre>
  
  <p>When I run the test, it never moves to the 'then' part after the promise. How do I test that the function inside the then part is actually called? </p>