I had a very sexy answer to the mockery of the tests, then I re-read your question and ... ugh.
The whole mechanism exports/ requireprovides dependency injection, and you can make fun or replace any module you need by simply changing require('module')to point to a new one.
You can even wrap any alternative API compatible libraries that you might want to disable. For example, if you were approaching a nervous breakdown, deciding to switch from underscore to lodash , you can simply create a module called underdash.js as follows:
if (process.env.COLD_SWEATS || process.env.SHAKING || process.env.PALPITATIONS) {
module.exports = exports = require('underscore');
} else {
module.exports = exports = require('lodash');
}
And then, when you need it, it’s simple require('./underdash'), and now you don’t need to worry about which library you are using down and can change it when you switch the switch - LONG LIKE THE API IS ALSO USED, otherwise you will have a bad time.