title: Jest how to wait for mock to be called based on simulate event
body: <p>I have a test like this which fails because mock is not called, the problem is that the mock is called but before test finished.</p>
  
  <pre><code>test('should submit if proper values', () =&gt; {
    const spy = jest.fn().mockReturnValue({
      data: {
        authenticateUser: {
          id: 123,
          token: 'lol'
        }
      }
    });
    mountedWrapper.setProps({
      loginMutation: spy
    });
    expect(spy).not.toHaveBeenCalled();
    email.simulate('change', {
      target: { name: 'username', value: 'email@test.com' }
    });
    password.simulate('change', {
      target: { name: 'password', value: 'secret' }
    });
    form.simulate('submit');
    expect(spy).toHaveBeenCalled();
  });
  </code></pre>
  
  <p>However I can get the test to pass if I add the following setTimeout</p>
  
  <pre><code>  setTimeout(() =&gt; {
      expect(spy).toHaveBeenCalled();
    }, 0);
  </code></pre>
  
  <p>However I am looking for a nicer approach to the above problem. Any solutions out there without setTimeout ?</p>