title: test function that returns ReactNode with Typescript and Jest
body: <p>I am trying to test a function that returns a <code>React.ReactNode</code> type, something like this:</p>
  <pre><code>export const getComponent = (
    storeParams: StoreParams,
    routeItem: RouteItem,
    Component: React.FunctionComponent&lt;{}&gt; | React.ComponentClass&lt;{}, any&gt;
  ): React.ReactNode =&gt; {
    if (isUnauthorized()) {
      return &lt;Error type=&quot;auth&quot; /&gt;;
    } else if (needsRedirect()) {
      return &lt;Redirect to=&quot;/privacy&quot; /&gt;;
    }
    return (
      &lt;React.Fragment&gt;
        &lt;Component /&gt;
      &lt;/React.Fragment&gt;
    );
  };
  </code></pre>
  <p>I am trying to write unit tests for it but I am not sure how I can confirm that the functions return the correct ReactNode.</p>
  <p>This is an example of the test:</p>
  <pre><code>test('return component', () =&gt; {
    const component = routes.find((r) =&gt; r.id === 'product');
  
    if (component) {
      const result = getComponent(
        { authorised: true, privacyAccepted: false },
        component,
        component?.component
      );
      // how do I check the component is correct?
    }
  });
  </code></pre>
  <p>I am not sure I can confirm the <code>result</code> is what I am expecting? For instance how do I check the  function return the <code>&lt;Redirect /&gt;</code> ?</p>