title: How do I test 'normal' (non-Node specific) JavaScript functions with Mocha?
body: <p>This seems like it <em>should</em> be extremely simple; however, after two hours of reading and trial-and-error without success, I'm admitting defeat and asking you guys! </p>
  
  <p>I'm trying to use <a href="http://visionmedia.github.com/mocha/" rel="noreferrer">Mocha</a> with <a href="https://github.com/visionmedia/should.js" rel="noreferrer">Should.js</a> to test some JavaScript functions, but I'm running into scoping issues. I've simplified it down to the most basic of test cases, but I cannot get it working. </p>
  
  <p>I have a file named <code>functions.js</code>, which just contains the following:</p>
  
  <pre><code>function testFunction() {
      return 1;
  }
  </code></pre>
  
  <p>And my <code>tests.js</code> (located in the same folder) contents:</p>
  
  <pre><code>require('./functions.js')
  
  describe('tests', function(){
      describe('testFunction', function(){
          it('should return 1', function(){
              testFunction().should.equal(1);
          })
      })
  })
  </code></pre>
  
  <p>This test fails with a <code>ReferenceError: testFunction is not defined</code>.</p>
  
  <p>I can see why, because most of the examples I've found either attach objects and functions to the Node <code>global</code> object or export them using <code>module.exports</code>—but using either of these approaches means my function code would throw errors in a standard browser situation, where those objects don't exist.</p>
  
  <p>So how can I access standalone functions which are declared in a separate script file from my tests, without using Node-specific syntax?</p>