I have a component which receives a component class of component to dynamically create as a child.
let componentFactory = this.componentFactoryResolver.resolveC
You can also do it into your test file directly if you want :
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; // DO not forget to Import
TestBed.configureTestingModule({
declarations: [ MyDynamicComponent ],
}).overrideModule(BrowserDynamicTestingModule, {
set: {
entryComponents: [ MyDynamicComponent ],
}
});
Okay, I figured it out. In the test you should define new module where you declare your mock component and specify it as an entryComponent
too.
@NgModule({
declarations: [TestComponent],
entryComponents: [
TestComponent,
]
})
class TestModule {}
And import it into TestBed
TestBed
.configureTestingModule({
declarations: [ValueComponent, TestHostComponent],
imports: [TestModule],
});
I hope it will help someone :]