node package manager

require-with

Dependency injection for Node.js

Require-with

Dependency injection for node.js

npm install --save require-with
var requireWith = require('require-with');
var mockFancify = requireWith('./fancifier', { 'leftpad': function(a){return a} });
 
expect(mockFancify(something)).toBeFancy();
expect(mockFancify(something)).not.toBeLeftpadded();