jeudi 9 août 2018

Angular 6 testing: How to provide services without their nested dependencies?

I have a ComponentA that uses an ServiceA. I'm writing a test for ComponentA, adding ServiceA into testbed providers. I run the test and get following error:

StaticInjectorError(DynamicTestModule)[ServiceA -> ServiceB]
NullInjectorError: No provider for ServiceB!

I add ServiceB to providers. I run the test again and now I get:

StaticInjectorError(DynamicTestModule)[ServiceB -> ServiceC]
NullInjectorError: No provider for ServiceC!

My project has many nested dependencies, all services have @Injectable decorator. How can I avoid providing long list of nested services?

Aucun commentaire:

Enregistrer un commentaire