DEV Community

Discussion on: Why do I have to use Dependency Injection in JS?

 
ld00d profile image
Brian Lampe

Isn't that the whole point though? You inject the npm modules with the sole purpose of mocking them. So in your unit test, you're not testing axios' connection to the web service, but via mocking, you can intercept those calls and stub a response for your unit test.