Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
fix: add null checks before removing parent refs
Browse files Browse the repository at this point in the history
This is to prevent the disable method to fail if there is anything on
the require cache object that does not have a parent element or
children on that parent object.

This fixes a problem introduced on PR
#57
  • Loading branch information
carlosvillademor committed Jun 19, 2017
1 parent ad2d727 commit e018f4c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mockery.js
Expand Up @@ -341,7 +341,7 @@ function removeParentReferences() {
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);
var idx = mod.parent && mod.parent.children && mod.parent.children.indexOf(mod);
if (idx > -1) {
mod.parent.children.splice(idx, 1);
}
Expand Down

0 comments on commit e018f4c

Please sign in to comment.