title: React Jest:- node:internal/process/promises:246 triggerUncaughtException(err, true /* fromPromise */);
body: <p>I have below code in react.</p>
  <pre><code>useEffect(() =&gt; {
          (async () =&gt; {
              await httpClient
                  .get(`${config.resourceServerUrl}/inventory/`)
                  .then((response) =&gt; {
                      setSponsor(response.data.sponsor);
                      setAddress(response.data.address);
                      setPhaseOfTrial(response.data.phaseOfTrial);
                  })
                  .catch((error) =&gt; {
                      alert(error);
                  });
          })();
      }, []);
  </code></pre>
  <p>this code works successfully. only issue is , it is failing in jest test case.</p>
  <pre><code>describe('ListInventory', () =&gt; {
      it('should render successfully', () =&gt; {
          const { baseElement } = render(&lt;ListInventory /&gt;);
          expect(baseElement).toBeTruthy();
      });
  });
  </code></pre>
  <p>Below is the error.</p>
  <pre><code>node:internal/process/promises:246
            triggerUncaughtException(err, true /* fromPromise */);
            ^
  
  [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason &quot;TypeError: Cannot read properties of undefined (reading 'get')&quot;.] {
    code: 'ERR_UNHANDLED_REJECTION'
  }
  </code></pre>
  <p>I am already using <code>catch</code> block. what wrong is in the code? could you please help me with the same.</p>