Depdency injection for Node.js
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
specs
.gitignore
README.md
index.js
package.json

README.md

Rerequire

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(/* path to module you want to test */, /* module mocks */, /* global mocks */);

Example

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