No tool is really important, it's just useful. It's not very known but RequireJS allows you to load files on diferent "contexts", I use this to create one context per test suite so in this context I can mock specific dependencies and they are not loaded.
I use "Multiversion" API to create one context per suite and "map" config parameter to mock dependencies:
http://www.requirejs.org/docs/api.html#config-maphttp://www.requirejs.org/docs/api.html#multiversion
requirejs.config({
map: {
'models/user': {
'srv/auth': 'test/mocks/srv/auth'
};
};
});
define(function(require) {
// if "../models/users" ask for module "srv/auth" require will delivery "test/mocks/srv/auth" instead
var userModel = require('../models/user');
// test
});