我有一个ComponentA
使用ServiceA
. 我正在为 编写一个测试ComponentA
,并添加ServiceA
到测试平台提供程序中。我运行测试并收到以下错误:
StaticInjectorError(DynamicTestModule)[ServiceA -> ServiceB]
NullInjectorError: No provider for ServiceB!
我添加ServiceB
到提供者。我再次运行测试,现在我得到:
StaticInjectorError(DynamicTestModule)[ServiceB -> ServiceC]
NullInjectorError: No provider for ServiceC!
我的项目有很多嵌套的依赖,所有的服务都有@Injectable
装饰器。如何避免提供一长串嵌套服务?