title: UnhandledPromiseRejectionWarning when testing React component with Jest
body: <p>So I want to test my <code>Login</code> component with Jest and React Testing Library.<br>
  Tests pass but I receive a:</p>
  
  <blockquote>
    <p>"UnhandledPromiseRejectionWarning".  </p>
  </blockquote>
  
  <p>How do I get rid of this message?</p>
  
  <p>This is the function I mock in top of the test file:</p>
  
  <pre><code>jest.mock('../../../api/endpoints/auth/login/login', () =&gt; {
    return {
      login: jest.fn()
    };
  });
  </code></pre>
  
  <p>And this is the function usage directly in test:</p>
  
  <pre><code>(login as jest.Mock).mockResolvedValueOnce(() =&gt; ({
    messages: ["Password is not correct"],
    isError: true
  }));
  act(() =&gt; {
    fireEvent.click(submitButton, leftClick);
  });
  
  await wait(() =&gt; {
    expect(getByTextLogin("Password is not correct")).toBeInTheDocument();
    expect(window.location.href).toContain('/login');
  });
  </code></pre>
  
  <p>Maybe I'm missing something when mocking an async function?</p>