title: Jest Mock API function causes react "act" warning and state does not gets updated
body: <p>Testing a React function component, this component on form submit calls a helper API function which I mocked.</p>
  
  <p>Below code gives me <em>Warning: An update to SomeComponent inside a test was not wrapped in act(...).</em> and does not update state of component.</p>
  
  <p>Component Pseudo Code</p>
  
  <pre><code>import React, { memo }  from "react"
  
  import { apiFunc } from "./API";
  
  function SomeComponent() {
      onSubmit = async () =&gt; {
          const response = await apiFunc();
  
          // DO something with response
      }
  
      return (
          &lt;form onSubmit={onSubmit}&gt;
              &lt;input type="text" /&gt;
          &lt;/form&gt;
      )
  }
  
  export default memo(SomeComponent)
  </code></pre>
  
  <p>Jest API mock <em>"API/__mocks__/API"</em></p>
  
  <pre><code>export const apiFunc = () =&gt; {
      return Promise.resolve({ message: "Success" });
  };
  </code></pre>
  
  <p>Jest test</p>
  
  <pre><code>jest.mock("./API")
  
  describe("&lt;SomeComponent /&gt;", () =&gt; {
      it("Submits form", () =&gt; {
          const wrapper = mount(&lt;Component /&gt;);
  
          wrapper
              .find(`input[aria-label="${TEXTS.EMAIL}"]`)
              .simulate("change", { target: { value: "test@test.com" } });
  
          wrapper.find("form").simulate("submit");
  
          expect(wrapper.find("div.fp-success")).toHaveLength(1);
      });
  });
  </code></pre>