Depdency injection

npm install rerequire
4 downloads in the last month


Dependency injection for Node.js modules. This module works the same as require but you can mock modules and globals.

var rerequire = require('rerequire');

rerequire(/* file to module you want to test */, /* module mocks */, /* global mocks */);


var test_file = rerequire('./test_files', {
  'http': 'http mock', // Mock global module
  './mod': 'mock mod', // Mock local module
}, {
  'Date': 'mock date', // Mock gloval
npm loves you