I have a component A that use a component B,c,D in its template:
###template-compA.html
<comp-b></comp-b>
<comp-c [myinput]="obj.myinput"></comp-c>
<comp-d ></comp-d>
...etc
To simplify, let's say their is only one directive in component A:
###template-compA.html
<comp-b></comp-b>
My comp-b has its own dependencies (services or other comp).
If I want to test comp-a this way:
TestBed.configureTestingModule({
declarations: [comp-A],
imports: [ReactiveFormsModule],
}).overrideComponent(FAQListComponent, {
set: {
providers: [
{ provide: comp-AService, useValue: comp-AListSVC }
]
}
})
.compileComponents();
it would not work properly. So I do:
TestBed.configureTestingModule({
declarations: [comp-A, comp-B],
imports: [ReactiveFormsModule],
}).overrideComponent(FAQListComponent, {
set: {
providers: [
{ provide: comp-AService, useValue: comp-AListSVC }
]
}
})
.compileComponents();
It doesn't work also because comp-b doesn't have its own dependencies. And here I am confused, how can I do unit test if I have to import and remock all others components every single time ? It looks like a very big amount of work. Is there another way? What would be the best practice to test component with nested componentS that have their own dependencies ?
Thanks a lot,
Stéphane.
schemas: [NO_ERRORS_SCHEMA]
? blog.nrwl.io/essential-angular-testing-192315f8be9b#.vygkcekn0 – Wrist