#Mock nested services
7 messages · Page 1 of 1 (latest)
If you mock ServiceA, then there would be no need to mock the nested one since there's nothing to inject it to. ServiceA has been replaced by a fske version.
Or are you possibly trying to test real instance of A in the UseCaseA and only moc the nested serviceB? That's also entirely possible via standard mocking syntax
{
providers: [
UseCaseA,
{
provide: ServiceA,
useValue: mockedServiceA
}
]
}
If you wish to write a test that uses both UseCaseA and serviceA, but mocks serviceB, follow the same pattern by including real classes in the test module and override those that should be mocked.
ServiceA depends on some methods from ServiceB, so i think i would need to mock those methods too
But if you're mocking service A, then nothing is using service B. It becomes entirely irrelevant for thre test.