DEV Community

Discussion on: Mocking dependencies with Jest + TypeScript

Collapse
 
viglioni profile image
Laura Viglioni

I recently had a problem while testing a NEST application where I had to check if some methods were using a specific decorator, it was a hell on earth, I'm not really a fan of dependency injection and this is one of the reasons haha

But in this text case, sometimes in a React application at some point, you need to have a component that talks with the external world, like in the example LaunchDarkly, and sometimes you can't just pass the function as a parameter, in my simplistic example here yes, but in real life not always, for instance, if this were a ReactHook, you can only call it in some specific points etc

To be frank this was the motivation I had to write this text