My question relates to Jasmine. Say I have the following graph of dependencies in an application:
SystemUnderTest --> Dependency1 --> Dependency2 --> DependencyN
Can I spy on DependencyN
even if it is not a direct dependency to the system under test (SystemUnderTest
) but rather a transitive dependency (only Dependency1
is a direct dependency above)?
It depends. In frameworks like AngularJS or Angular2 that make use of dependency injection, mocking (or spying on methods of) a service will inject the mocked version for any other components or child components that would normally use this same service.