title: mocha, node.js, ReferenceError: Board is not defined
body: <p>I'm new with node.js and I'm trying to collaborate in a project adding a mocha test suite for it. The issue that I have at the moment is the following</p>
  
  <pre><code>ReferenceError: Board is not defined
  at new Game (/Users/.../dr_mojo/public/javascripts/game.js:8:20)
  at Context.&lt;anonymous&gt; (/Users/.../dr_mojo/test/test.game.js:13:17)
  at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:213:32)
  at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:343:10)
  at Runner.runTests.next (/usr/local/lib/node_modules/mocha/lib/runner.js:389:12)
  . . .
  </code></pre>
  
  <p>when run my test with </p>
  
  <pre><code>$&gt; mocha -u tdd test/test.game.js --reporter spec
  </code></pre>
  
  <p><b>public/javascripts/board.js</b></p>
  
  <pre><code>function Board(width, height) {
    this.board = new Array(width);
    this.width = width;
    this.height = height;
    for( var i = 0; i &lt; width ; ++i) {
      this.board[i] = new Array(height);
    }
  }
  ...
  if(typeof module != 'undefined') {
    module.exports.Board = Board;
  }
  </code></pre>
  
  <p><b>public/javascripts/game.js</b></p>
  
  <pre><code>function Game(lvl, speed, music) {
    this.initial = { ... };
    this.board = new Board(board_size[0], board_size[1]);
    ...
  }
  ...
  if(typeof module != 'undefined') {
    module.exports.Game = Game;
  }
  </code></pre>
  
  <p><b>test/test.game.js</b></p>
  
  <pre><code>var assert = require("assert");
  var Board  = require(__dirname + "/../public/javascripts/board.js").Board;
  var Pill   = require(__dirname + "/../public/javascripts/pill.js").Pill;
  var Game   = require(__dirname + "/../public/javascripts/game.js").Game;
  
  describe('Game', function(){
    it('Clears a row', function(){
      var game  = new Game();
      var pill1 = new Pill(game.board, game.detector, [ {x : 0 , y : 0 }, {x : 1, y : 0 } ],["red", "red"]);
      var pill2 = new Pill(game.board, game.detector, [ {x : 2 , y : 0 }, {x : 3, y : 0 } ],["red", "red"]);
  
      assert.equal(game.board.matches().length, 1);
  
      game.findMatches(function(){});
      assert.equal(game.board.matches().length, 0);
    })
  })
  </code></pre>
  
  <p><b>server.js</b></p>
  
  <pre><code>var express = require('express'),
      port    = 8888;
  
  var app = express.createServer();
  
  app.use(express.static(__dirname + '/public'));
  app.set("view engine", "jade");
  app.set('view options', { layout: false });
  
  app.get('/play', function(req, res){
    res.render('play_game');
  });
  
  app.listen(port);
  </code></pre>
  
  <p>As you can see the error is in <code>game.js:8</code> the thing is that I don't know how to configure it properly given that when the game is playing it works ok, this means that <code>new Game()</code> works ok and the problem is that I'm not configuring it properly from the test suite. I'll appreciate any help. Thanks in advance.</p>