Angular 2.0.0 - Testing “ imported by the module 'DynamicTestModule' ”

那年仲夏 提交于 2019-12-03 01:25:56
manjunath shanbhag

HomeModuleComponent is Component not the Module, so it has to be in declarations:

TestBed.configureTestingModule({
  declarations: [AppComponent, HomeModuleComponent],
  imports : [ ]
});

and then you can create the component to test as,

TestBed.createComponent(AppComponent);

In my test spec, by mistake I was importing a service instead of providing it. I was getting the same error.

Adding the service back inside providers array resolved my error.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!