-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I love this library; it's very elegant. I noticed that running a test individual can have different results than running the whole suite. Since node caches the modules, future requests are pulled from cache and don't have a chance to get intercepted.
Any thoughts on how to handle this?
At first I thought you could clear the cache for the newly mocked libraries each time, but it gets tricky when you're mocking a dependency of a dependency. I'm using mocha, so maybe other test suites handle this better.
For what it's worth, running this before each test fixes the problem (but it's overkill):
for (prop in require.cache)
if (require.cache.hasOwnProperty(prop))
delete require.cache[prop];
Metadata
Metadata
Assignees
Labels
No labels