title: Is there a Java classpath-like feature for server-side Javascript?
body: <p>When using JUnit and Maven in Java, one can have separate property files for <code>src/main</code> and <code>src/test</code>. This allows different configuration for code and tests, having Maven to manage the resources by using Java classpath. </p>
  
  <p>Is there a similar way in Javascript code run by Node.js? I use Mocha for unit-testing and Grunt for task management.</p>
  
  <p>Code example for <code>script.js</code>:</p>
  
  <pre><code>var config = require('./config/dev/app.js');
  
  exports.getFileName = function() {
      return config.fileName; // returns 'code.txt'
  }
  </code></pre>
  
  <p>What I need is to make the <code>script.js</code> use different config file when being required in a <code>test.js</code> unit test like this:</p>
  
  <pre><code>var assert = require('assert');
  var s = require('./script.js');
  
  describe('Test', function () {
      it('should use different config file', function() {
          assert.equal('test.txt', s.getFileName());
      });
  });
  </code></pre>
  
  <p>Is there a way to use different configuration <code>./config/test/app.js</code> in the <code>script.js</code> without having to alter the code of <code>script.js</code>? What I really try to avoid is to adjust the code to support unit tests. Instead, I want to achieve similar functionality such as mentioned Java classpath.</p>