mfncooper / mockery

Simplifying the use of mocks with Node.js
Other
1.1k stars 60 forks source link

fix: add null checks before removing parent refs #64

Closed carlosvillademor closed 7 years ago

carlosvillademor commented 7 years ago

One of our projects has a dependency to newrelic module, currently to version 1.40.0. The newrelic module code, attaches a property to the require.cache object, see https://github.com/newrelic/node-newrelic/blob/master/index.js#L114.

When calling the disable method on mockery, version 2.0.0, it will break, because the code on https://github.com/mfncooper/mockery/pull/57 assumes that anything on the require.cache object will be a module with a parent property. This is not the case with this newrelic module, and potentially with another ones attaching stuff to the rquire.cache.

davglass commented 7 years ago

Published in mockery@2.1.0