Permalink
Browse files

noPreserveCache functionality restored

Fixes #35
  • Loading branch information...
1 parent 921f7ad commit 35ba46b407a958a29bf2828a74741479e980da36 @bitsoflogic bitsoflogic committed with May 30, 2014
Showing with 9 additions and 0 deletions.
  1. +2 −0 lib/proxyquire.js
  2. +7 −0 test/proxyquire-cache.js
View
@@ -171,6 +171,8 @@ Proxyquire.prototype._withoutCache = function(module, stubs, path, func) {
// Restore the cache if we are preserving it
if (this._preserveCache) {
restoreCache();
+ } else {
+ delete require.cache[Module._resolveFilename(path, module)];
}
// Finally restore the original extension handlers
@@ -74,5 +74,12 @@ describe("Proxyquire", function() {
assert.equal('', foo.state);
assert.notEqual(foo, original);
});
+
+ it('deletes the require.cache for the module being stubbed', function() {
+ var proxyquire = require('..').noPreserveCache();
+
+ var foo = proxyquire.load('./samples/foo', { 'path': { } });
+ assert.equal(undefined, require.cache[require.resolve('./samples/foo')]);
+ });
});
});

0 comments on commit 35ba46b

Please sign in to comment.