require-cache-mock
Requiring this package will allow you to mock modules from anywhere in your node project
Combine this feature with bundl-pack to get the same results in a browser
Uses mock-require under the hood to facilitate mocking
Note: Using this package modifies your global require
Install
$ npm install require-cache-mock
Use
Where replacement
is an object or function to return in place of the original module:
requirecache;
Example
; var entry = ; entry; // two is mocked
entry.js
requirecache; { var one = ; console;} moduleexports = init: init ;
one.js
var two = ; moduleexports = twoType: twotype;
two.js
moduleexports = type: 'real';
Stop Mocking
requirecachemock;
Additional Options
See mock-require for more details
requirecachemock === ;