title: React, Jest, and Testing Library: TypeError: Cannot read property 'createEvent' of null when using findBy such as findByAltText
body: <h2>Problem</h2>
  <p>When I try to run my tests via <code>npm test</code> using Jest, with React, and Testing Library I get the following error:</p>
  <h2>Error</h2>
  <pre class="lang-sh prettyprint-override"><code>/node_modules/react-dom/cjs/react-dom.development.js:3905
        var evt = document.createEvent('Event');
                           ^
  
  TypeError: Cannot read property 'createEvent' of null
      at Object.invokeGuardedCallbackDev (/node_modules/react-dom/cjs/react-dom.development.js:3905:26)
      at invokeGuardedCallback (/node_modules/react-dom/cjs/react-dom.development.js:4056:31)
      at flushPassiveEffectsImpl (/node_modules/react-dom/cjs/react-dom.development.js:23543:11)
      at unstable_runWithPriority (/node_modules/scheduler/cjs/scheduler.development.js:468:12)
      at runWithPriority$1 (/node_modules/react-dom/cjs/react-dom.development.js:11276:10)
      at flushPassiveEffects (/node_modules/react-dom/cjs/react-dom.development.js:23447:14)
      at Object.&lt;anonymous&gt;.flushWork (/node_modules/react-dom/cjs/react-dom-test-utils.development.js:992:10)
      at Immediate.&lt;anonymous&gt; (/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1003:11)
      at processImmediate (node:internal/timers:464:21)
  /node_modules/react-dom/cjs/react-dom.development.js:3905
        var evt = document.createEvent('Event');
  </code></pre>