mfncooper / mockery

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

Fixed an apparent loss of the original loader #33

Open davidporter-id-au opened 9 years ago

davidporter-id-au commented 9 years ago

I was getting an error with the originalLoader being lost somehow during my tests. I suspect it was because I was probably doing a combination of resetting caches and re-requiring in mockery in a cavalier fashion.

Either way, by taking the reference out of the mockery closure and putting it on the module, it no longer suffers from this problem.

cspotcode commented 8 years ago

I think requiring mockery from inside a test where the cache has been cleared will have other ill effects. For example, mockery also stores info about stubs and mocks, not just originalLoader, inside its closure.

I've fixed this in mockery-next by attaching a reference to mockery itself to module. See cspotcode/mockery-next#7