title: Jest TypeError: Cannot read property of null
body: <p>I have a setup for an external application and start it within a const, then put it in the <strong>const allowAppInstance</strong> the configuration of the appConfig</p>
  <pre><code>export const setupRemote = () =&gt; {
    if (isRemoteAvailable) {
      try {
        ...
  
        const allowAppInstance = SetupConfig.start(remoteInstance);
  
        return {
          allowAppInstance,
        };
      } catch (e) {
        console.error(e);
      }
    }
  };
  </code></pre>
  <p>here I export</p>
  <pre><code>export const appSetupConfig = () =&gt; setupRemote().allowAppInstance;
  </code></pre>
  <p>in the component, I get this setup and put it in a const</p>
  <pre><code>import { appSetupConfig } from '.../myapp'
  
        useEffect(() =&gt; {
          const allowAppInstance = appSetupConfig();
      
          ...the rest of code
      
        }, []);
  </code></pre>
  <p>the application works, <strong>but when I run the tests, jest doesn't let it pass, it causes this error:</strong></p>
  <pre><code>  TypeError: Cannot read property 'allowAppInstance' of null
  
    43 | };
    44 | 
  &gt; 45 | export const appSetupConfig = () =&gt; setupRemote().allowAppInstance;
  </code></pre>
  <p>Is there any way to mock <strong>allowAppInstance</strong> to pass the test? I really don't know what to do and what am I doing wrong</p>