I am new to Jest and unit testing and I am not sure how to handle mocking in case of relatively deep invocation structures. Let's say we have the following app structure:
Given the grey classes (axios and cache) are external, 3rd party modules, I need to write unit tests for Domain.createUser and Backend.postUsers methods.
I have clear that within the Backend.postUser tests I need to mock axios.
In case of Domain.createUser, I would certainly mock cache, but I am not sure what to do with its second dependency.
Should I just mock Backend.postUser (as a direct dependency) or somehow indirectly mock just axios (as external dependency)?
Or both approaches work in different setups?
If so, what criteria should I use to make decision what is the best strategy?
