Proxyquire
Proxies nodejs require in order to allow overriding dependencies
...It allows a module under test to receive stubs in place of selected internal dependencies without modifying production code. Any methods not explicitly replaced can continue calling through to the original dependency by default. Strict no-call-through behavior can be enabled when complete isolation is required. The library is independent of a specific mocking framework, so it works with any tool capable of providing compatible stubs. Advanced options can simulate missing modules, reload modules, and override dependencies during initialization or runtime. ...