title: Mock window.performance.getEntriesByType
body: <p>In my component I check whether the page is reloaded and redirect to another page. I do it by following code.</p>
  <pre><code>useEffect(() =&gt; {
      //this will prevent users from accidently refreshing / closing tab
      window.onbeforeunload = () =&gt; {
        return &quot;&quot;;
      };
     //check whether user reloaded
      if (
        window.performance.getEntriesByType(&quot;navigation&quot;)[0].type === &quot;reload&quot;
      ) {
        openExternalURL(process.env.GATSBY_MARKETING_URL);
      }
    }, []);
  </code></pre>
  <p>problem is I keep getting error in my Jest / react-test-library test cases as below</p>
  <pre><code>TypeError: window.performance.getEntriesByType is not a function
  </code></pre>
  <p><a href="https://i.stack.imgur.com/0KyqB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0KyqB.png" alt="enter image description here" /></a></p>
  <p>Even I tried to mock it like below but had no success.</p>
  <pre><code>window.performance = {
    getEntriesByType: jest.fn().mockReturnValue([{ type: &quot;reload&quot; }]),
    measure: jest.fn()
  };
  </code></pre>
  <p>Can someone point me to the right direction? thanks in advance.</p>