title: Jsdom.env to new JSDOM , migration
body: <blockquote>
    <p>Background</p>
  </blockquote>
  
  <p>So, I have been following through a tutorial to understand the JS testing frameworks and have learned that to get the Web UI tested it is preferred to utilise the <strong>JSDOM</strong> library is it doesn't require the browser and brings the DOM which can then be executed in a Headless Fashion.</p>
  
  <p>For the Assertion Library, I am using <strong>Chai</strong> and as a testing framework I have opted <strong>Mocha</strong></p>
  
  <blockquote>
    <p>Test Case : I would like to test an html file by reading its h1 tag's value i.e. Hello World in this case and I would assert it to true.</p>
  </blockquote>
  
  <pre><code>import {expect} from 'chai'
  import jsdom from 'jsdom'
  import fs from 'fs'
  
  describe('index.html', () =&gt; { // eslint-disable-line
    it('should say hello' , () =&gt; { // eslint-disable-line
      const index = fs.readFileSync('./src/index.html', 'utf-8')
      jsdom.env(index, function (err, window) { // eslint-disable-line
        const h1 = window.document.getElementsByTagName('h1')[0]
        expect(h1.innerHTML).to.equal('Hello World!')
        window.close()
      })
    })
  })
  </code></pre>
  
  <p>This would work fine for an older version of <strong>JSDOM</strong> package but as I have checked the JSDOM docs i.e. <a href="https://github.com/jsdom/jsdom" rel="nofollow noreferrer">https://github.com/jsdom/jsdom</a> the new way of doing this is JSDOM constructor. </p>
  
  <p>So, how can I migrate this test case to adhere with the updated style of JSDOM library.</p>