title: Why are mocha test not running? - node.js
body: <p>I am working through <strong>web development with node and express</strong> from O'reilly. Testing with Mocha has just been introduced and I am trying to run 2 tests. First is a global test to verify that there is a page title, second is a page specific test to check for a link to the contact page.
  Mocha loads when I test the page, but neither test runs, as I get "passes:0 fails:0".</p>
  
  <p>I have this code in my main app file:</p>
  
  <pre><code>app.use(function(req,res,next){
      res.locals.showTests = app.get('env') !== 'production' &amp;&amp; req.query.test === '1';
      next();
  });
  
  app.get('/', function(req, res){
      res.render('home');
  });
  app. get('/about', function(req,res){
      res.render('about', {fortune: fortune.getFortune(),
          pageTestScript: '/qa/tests-about.js'
          });
  
  });
  </code></pre>
  
  <p>This is my tests-about.js</p>
  
  <pre><code>suite('"About" Page Tests', function(){
      test('page should contain link to contact page', function(){
          assert($('a[href="/contact"]').length);
  
      });
  });
  </code></pre>
  
  <p>This is my tests-global.js</p>
  
  <pre><code>suite('Global Tests', function(){
      test('page has a valid title', function(){
          assert(document.title &amp;&amp; document.title.match(/\S/) &amp;&amp;
              document.title.toUpperCase() !=== 'TODO');
      });
  });
  </code></pre>
  
  <p>This is my main template file (handlebars)</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Random Pixel Media&lt;/title&gt;
      {{#if showTests}}
      &lt;link rel="stylesheet" href="/vendor/mocha"&gt;
      {{/if}}
      &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;header&gt;&lt;a href="/"&gt;&lt;img src="/img/logo.png" alt="Random Pixel Logo" /&gt;&lt;/a&gt;&lt;/header&gt;
      {{{body}}}
      {{#if showTests}}
      &lt;div id="mocha"&gt;&lt;/div&gt;
      &lt;script src="/vendor/mocha.js"&gt;&lt;/script&gt;
      &lt;script src="/vendor/chai.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          mocha.ui('tdd');
          var assert = chai.assert;
      &lt;/script&gt;
      &lt;script src="/qa/tests-global.js"&gt;&lt;/script&gt;
      {{#if pageTestScript}}
          &lt;script src="{{pageTestScript}}"&gt;&lt;/script&gt;
      {{/if}}
      &lt;script&gt;mocha.run();&lt;/script&gt;
      {{/if}}
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>According to the book, I should be seeing 2 suites and 1 failure when I visit the about page, but as I stated, I see a blank bullet point, passes:0 and fails:0
  Any help to understand what I'm missing would be greatly appreciated.</p>