vendredi 6 octobre 2017

how to avoir the dependencies hell with unit test in angular 2+

i see lots of examples about how to unit test simple components in angular 2+, but when it comes to test components who use services, it becomes a nightmare to maintain the test bed providers and imports. how can i avoid it ?

for example i have myComponents, who uses myService, who uses HttpClient. To test myComponent i must setup the providers for myService and HttpClient. If i add an other service to the constructor of myService, i will have to edit ALL the testbeds of the cmoponents who use this service.

can't i tell the testbed to fetch the default dependencies for these modules?

Aucun commentaire:

Enregistrer un commentaire