Skip to content

Instantly share code, notes, and snippets.

@andyperlitch
Last active December 19, 2015 13:19
Show Gist options
  • Save andyperlitch/5961510 to your computer and use it in GitHub Desktop.
Save andyperlitch/5961510 to your computer and use it in GitHub Desktop.
var originals = {};
exports = module.exports = {
registerMock: function(key, mock, module) {
var map = module.map;
var cache = module.cache;
originals[map[key]] = cache[map[key]].exports;
cache[map[key]].exports = mock;
},
unregisterMock: function(key, module) {
var map = module.map;
var cache = module.cache;
cache[map[key]].exports = originals[map[key]];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment