Comparing version 1.7.0 to 2.0.0
@@ -159,2 +159,3 @@ /* | ||
}); | ||
removeParentReferences(); | ||
m._cache = originalCache; | ||
@@ -175,2 +176,3 @@ originalCache = null; | ||
if (options.useCleanCache && originalCache) { | ||
removeParentReferences(); | ||
m._cache = {}; | ||
@@ -335,2 +337,19 @@ repopulateNative(); | ||
/** | ||
* Remove references to modules in the mockery cache from | ||
* their parents' children. | ||
*/ | ||
function removeParentReferences() { | ||
Object.keys(m._cache).forEach(function(k){ | ||
if (k.indexOf('\.node') === -1) { | ||
// don't touch native modules, because they're special | ||
var mod = m._cache[k]; | ||
var idx = mod.parent.children.indexOf(mod); | ||
if (idx > -1) { | ||
mod.parent.children.splice(idx, 1); | ||
} | ||
} | ||
}); | ||
} | ||
// Exported functions | ||
@@ -337,0 +356,0 @@ exports.enable = enable; |
{ | ||
"name": "mockery", | ||
"version": "1.7.0", | ||
"version": "2.0.0", | ||
"description": "Simplifying the use of mocks with Node.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
# Mockery - Simplifying the use of mocks with Node.js | ||
[![Build Status](https://secure.travis-ci.org/mfncooper/mockery.png)](http://travis-ci.org/mfncooper/mockery) | ||
[![Build Status](https://secure.travis-ci.org/mfncooper/mockery.svg)](http://travis-ci.org/mfncooper/mockery) | ||
@@ -5,0 +5,0 @@ If you've tried working with mocks in Node.js, you've no doubt discovered that |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49186
954