A require in Node code can be mocked using the mock-require package:

var mockRequire = require('mock-require');

mockRequire('foo', { /* mock export */ }});

var foo = require('foo');

Seems that it depends on monkey-patching Module._load. More information can be found here. I wouldn’t mess with Module._load outside of test code.