#Unit Test Questions Provider files

4 messages · Page 1 of 1 (latest)

steep sonnet
#

I'm trying to do unit testing.

My concern is that if the mocked provider is injecting another provider, should that target also be mocked?

ex) userController -> UserService -> UserRepo
-> FileRepo
-> AdminRepo

users.controller.ts has provider users.service.ts

If fileRepo and adminRepo are being injected from users.service, do I need to mock those two files as well?

flat coral
#

Mocking is only simulating what the dependency would offer. Thus, you only need to mock the highest level dependencies.

steep sonnet
#

Thank you.

Do you have any references? How do I find references?

flat coral
#

The internet is full of them. Google it. 🙂