
Dependency Injection in Node.js - kostarelo
https://kostasbariotis.com/dependency-injection-in-node-js/
======
tthisk
Why would you need dependency injection if you can dynamically replace
imported modules through Node's module system?

~~~
kostarelo
Are you referring to the `cache` property of the the module system? I
personally consider this to be similar to monkey patch and way out of the
reason of what was built for. It also restricts you in ways like having to set
that up before calling the module that you want to test which for testing may
lead to bloated test files.

With DI, you are treating any dependency the same way. Modules both external
and yours codebase, environment variables and process information, etc.

