I'm testing a component that uses a directive inside a contentchildren decorator in order to access to its content in order to transclude it.
@ContentChildren(CarouselItemDirective) items: QueryList<CarouselItemDirective>;
I tried to create a stub with the same name and add it to my testbed testing module:
function testModuleSetup() {
TestBed.configureTestingModule({
declarations: [
CarouselComponent,
CarouselItemDirective,
TestHostComponent]
});
}
Using the stub version of CarouselItemDirective the content is not transcluded, but importing and using the original directive it works as expected.
CarouselItemDirective was not injected in the component's constructor so I suppose this is the problem . How can i mock it?
A similar case can be found here. How can AdDirective be mocked when testing AdBannerComponent in this case.
Aucun commentaire:
Enregistrer un commentaire