How to unit test components with react hooks? : <p>Currently trying to unit test components with hooks (useState and useEffects).
As I have read, lifecycles can only be tested with a mount and not a shallow render.</p>

<p>Implementation code:</p>

<pre><code>export function MainPageRouter({issuerDeals, match, dbLoadIssuerDeals}) {
console.log("MainPageRouter")
const [isLoading, setIsLoading] = useState(true);


const selectedIssuerId = match.params.id;
const issuerDeal = filterIssuerDealByIssuerId(issuerDeals, 
selectedIssuerId);

useEffect(() =&gt; {
   dbLoadIssuerDeals(selectedIssuerId)
     .then(() =&gt; {
        setIsLoading(false);
      })
     .catch(function (error) {
        setIsLoading(false);
        });
  }, [selectedIssuerId]);

  if (isLoading) {
    return &lt;MainPageLoading /&gt;
  } else if(issuerDeal.length &gt; 0) {
    return &lt;MappedDeal match={match}/&gt;
  } else {
    return &lt;MapDeal match={match}/&gt;
  }

}

const mapStateToProps = state =&gt; {
  return {
    deals: state.deals,
    issuerDeals: state.issuerDeals
  }
};

const mapDispatchToProps = {
  dbLoadIssuerDeals
}

export default connect(mapStateToProps, mapDispatchToProps)(MainPageRouter);
</code></pre>

<p>However doing so results in this error: </p>

<pre><code>Warning: An update to MainPageRouter inside a test was not wrapped in 
act(...).

When testing, code that causes React state updates should be wrapped into 
act(...):

act(() =&gt; {
  /* fire events that update state */
});
</code></pre>

<p>Test:</p>

<pre><code>it('Should render Mapped Deal', () =&gt; {
    const dbLoadIssuerDeals = jest.fn(() =&gt; Promise.resolve({
        payload:{ deals: { dealid: "1", sourceCode: "TEST" }, issuerId: "1" } }))
    const props = createProps(issuerDeals, dbLoadIssuerDeals);
    const mainPageRouter = mount(&lt;MemoryRouter&gt;&lt;MainPageRouter{...props} /&gt;&lt;/MemoryRouter&gt;);
});
</code></pre>

<p>Is there a clean way to test that mainPageRouter would return back MappedDeal or MapDeal? I also understand that using mount is more towards integration tests.</p>
