title: Using Chai to test value of HTML element
body: <p>I'm learning Mocha and Chai and am trying to write a test to check the value of the H1 tag on a page.  I have the test below which attempts to do this in three of ways:</p>
  
  <pre><code>const expect  = require('chai').expect;
  const assert = require('chai').assert;
  const request = require('request');
  const chaiHttp = require('chai-http');
  const app = require('../../app');
  const chai = require('chai');
  chai.use(require('chai-dom'));
  chai.use(chaiHttp);
  
  //first attempt
  describe('Story Homepage', function(){
    it('Should have an H1 of My Home Page', function(){
    chai.request(app)
    .get('/', function (){
       expect(document.querySelector('h1')).should.have.text('My Home Page');
       });
    })
  });
  
  //second attempt
  describe('Story Page Tests', function () {
  it('Homepage H1 is My Home Page', function(done) { 
      chai.request(app)
      .get('/', function(done){
        expect(document.querySelector('h1').should.have.text('My Home Page'));
        done(); 
      })
    });
  });
  
  
  //third attempt
  describe('Story Page Tests', function () {
    it('Homepage H1 is My Home Page', function(done) { 
        chai.request(app)
        .get('/')
        .end(function(err, res) {
          expect(document.querySelector('h1').should.have.text('My Home Page'));
        done();                               
      });
    });
  });
  </code></pre>
  
  <p>I've attempted to use the chai-dom extension in the way described here <a href="https://github.com/nathanboktae/chai-dom#texttext" rel="nofollow noreferrer">https://github.com/nathanboktae/chai-dom#texttext</a> to do this. 
  However:
  The first test passes but should not pass (the  on the page is not the same as asserted by the test)</p>
  
  <p>The second of the tests reports an error <code>Error: Timeout of 15000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.</code>  but I think that I am using <code>done</code> correctly above.</p>
  
  <p>The third test reports an error <code>Uncaught ReferenceError: document is not defined</code> which seems logical but I'm not really sure how to resolve it.</p>
  
  <p>Does anyone offer advice on how to do this correctly?</p>