title: How to test nodelist with Jest
body: <p>I try to test with Jest a javascript function that check if a variable is a nodelist.
  It's a browser function and that will be used in browser.
  here is the function :</p>
  
  <pre><code>/**
   * @description Check if input is a nodelist and return true or false.
   * @export
   * @param {*} input
   * @returns {boolean}
   */
  export function $isNodeList(input) {
      return NodeList.prototype.isPrototypeOf(input);
  }
  </code></pre>
  
  <p>The function work well in browser but if I try to test it with jest, I get the following error : <em>ReferenceError: NodeList is not defined</em></p>
  
  <p>The test file is :</p>
  
  <pre><code>const esmImport = require("esm")(module);
  const mod = esmImport("../tools/is_nodelist.js");
  
  const html = '&lt;!DOCTYPE html&gt;\
                  &lt;html&gt;\
                      &lt;body&gt;\
                          &lt;div&gt;Hello world&lt;/div&gt;\
                          &lt;div&gt;Hello&lt;/div&gt;\
                          &lt;div&gt;...&lt;/div&gt;\
                      &lt;/body&gt;\
                  &lt;/html&gt;';
  
  const jsdom = require("jsdom");
  const { JSDOM } = jsdom;
  const { document } = (new JSDOM(html)).window;
  
  global.document = document;
  
  test("expect nodeList to be nodelist", () =&gt; {
      let nodeList = global.document.querySelectorAll("div");
      expect(mod.$isNodeList(nodeList)).toBe(true);
  });
  
  test("expect htmlCollection not to be nodelist", () =&gt; {
      let htmlCollection = global.document.getElementsByTagName("div");
      expect(mod.$isNodeList(htmlCollection)).toBe(false);
  });
  </code></pre>
  
  <p>What is wrong in my test and how correctly test that function?</p>