Mock a Node module's dependencies using Proxyquire
Sometimes when writing a unit test, you know that the module you're testing imports a module that you would like to observe, or at the very least mock to prevent side effects like network activity or file system operations.
require function by using the
proxyquire module, which allows us to mock one or more modules that are second-class dependencies in our unit test, replacing them with whatever we want.
In this video, we'll demonstrate the basics of using Proxyquire to prevent and observe a file system operation.