Q:

Mocha Chai source file path length required in spec file

Just started playing with Mocha Chai but can't find how to simplify the path to the source file used in the spec file.
We have project src and test directory hierarchy.  In the spec file, there is a require that looks like:
var somecode = require('../../../src/a/fun/lib/somecode');
Can't I have a $srcpath and $testpath?
var somecode = require('$srcpath/a/fun/lib/somecode');
Even better would be $srcpath/$relativepath/somecode.
NOTE:  tests are running recursively.

A:

In all my test files I use the following to load a module from the root of the project:
describe('...', function() {
    ...
    var path = require('path');
    var basedir = path.resolve('./');

    var moduleToTest = require(path.resolve(basedir, 'lib/path/to/moduletotest'));
    ...

for paths relative to the current spec just replace the basedir with __dirname

