mercredi 10 octobre 2018

What are the best practices for Testing in Angular?

I have an AppComponent and in its html template, I have BannerComponent and WelcomeComponent (indicated by <app-banner> and <app-welcome>). So in the test case, if I declare the real components, I'll also have to declare their nested components and provide for all services injected in any component in the tree. What is the recommended practice? Can I just use imports: [ AppModule ] or do I declare all the components and their nested components and all the services injected into them??

If I just import AppModule, will it take the real RouterModule (if used by the AppModule) or can I just override it by using RouterTestingModule??

If I declare all the component, will give me a better idea that the component under test integrates well with all the other dependent components. Is it a good practice? Also, is it a good practice to use APP_ERRORS_SCHEMA?

Aucun commentaire:

Enregistrer un commentaire