Providing “entryComponents” for a TestBed

前端 未结 2 661
余生分开走
余生分开走 2021-02-01 01:05

I have a component which receives a component class of component to dynamically create as a child.

let componentFactory = this.componentFactoryResolver.resolveC         


        
2条回答
  •  余生分开走
    2021-02-01 01:43

    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 ],
      }
    });
    

提交回复
热议问题