title: Unit testing React click outside component using Jest and react testing library
body: <p>I found this implementation here but its using enzyme.</p>
  
  <p><a href="https://stackoverflow.com/questions/45046728/unit-testing-react-click-outside-component">Unit testing React click outside component</a></p>
  
  <p>Adding an event to window does not work either:</p>
  
  <pre><code>window.addEventListener('click', () =&gt; {
        console.log('click on window');
      });
  </code></pre>
  
  <p>Has anyone came across this issue above using jest and "@testing-library/react"?</p>