rewire icon indicating copy to clipboard operation
rewire copied to clipboard

Add ability to invalidate require cache on rewired file

Open mboudreau opened this issue 9 years ago • 2 comments

While running these tests, I'm trying to clear the require cache for every test to try to 'sandbox' things and not things set outside the export interfere when they're in a different state.

I would like a way to be able to force invalidate the cache when trying to rewire. Currently I have a workaround of deleting it manually before the test starts, but I think it would be neat if I could simply do rewire('./file', true) to force it to invalidate and get the new rewired file. I've modified it on my fork showing what I mean which could be cleaned up or adding at a better place.

mboudreau avatar Dec 30 '16 03:12 mboudreau

Rewire will always return a new instance of the module. See the Caveats section in the readme.

JvJefke avatar Nov 15 '17 20:11 JvJefke

@JvJefke but sub-dependencies aren't, which kinds of defeat the purpose.

mboudreau avatar Nov 15 '17 22:11 mboudreau