title: node js chai mocha "ReferenceError: Can't find the variable require"
body: <p>I am using grunt, mocha, and chai to run a basic unit test.  My unit test looks like the following</p>
  
  <pre><code>describe('SPSearchConnection', function () {
  describe('#performSearch()', function () {
      it('should return zero or more results', function () {
          var spSearchConnect = require('../index');
          alert(spSearchConnect);
          chai.assert.equal(-1, [1, 2, 3].indexOf(5));
      });
  });
  });
  </code></pre>
  
  <p>Now when I run the test using grunt "grunt" I get the following error:</p>
  
  <pre><code>ReferenceError: Can't find variable: require
  </code></pre>
  
  <p>My gruntfile.js looks like this :</p>
  
  <pre><code>// Gruntfile.js
  module.exports = function (grunt) {
  grunt.initConfig({
      pkg: grunt.file.readJSON('package.json'),
  
      // Mocha
      mocha: {
          all: {
              src: ['tests/testrunner.html'],
          },
          options: {
              run: true
          }
      }
  });
  
  // Load grunt mocha task
  grunt.loadNpmTasks('grunt-mocha');
  
  grunt.registerTask('default', ['mocha']);
  </code></pre>
  
  <p>};</p>
  
  <p>My testrunner.html file looks like this :</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Mocha Tests&lt;/title&gt;
  &lt;link rel="stylesheet" href="../node_modules/mocha/mocha.css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="mocha"&gt;&lt;/div&gt;
  &lt;script src="../node_modules/mocha/mocha.js"&gt;&lt;/script&gt;
  &lt;script src="../node_modules/chai/chai.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
      mocha.setup('bdd')
      mocha.reporter('html');
  &lt;/script&gt;
  
  &lt;!-- Tests --&gt;
  &lt;script src="tests.js"&gt;&lt;/script&gt;
  
  &lt;!-- Tests --&gt;
  &lt;script&gt;&lt;/script&gt;
  
  &lt;script&gt;
      // Only tests run in real browser, injected script run if options.run == true
      if (navigator.userAgent.indexOf('PhantomJS') &lt; 0) {
          mocha.run();
      }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can someone tell me how to fix this please?</p>