我正在尝试运行单元测试,该测试使用注入的路由器测试组件。这是我的设置代码...
TestBed.configureTestingModule({
declarations: [PeopleComponent, PersonComponent],
providers: [
{
provide: Http, useFactory: (backend, options) => {
return new Http(backend, options);
},
deps: [MockBackend, BaseRequestOptions]
},
MockBackend,
BaseRequestOptions,
PeopleRepository,
PeopleViewModelLoader,
PersonViewModelLoader,
{provide: APP_BASE_HREF, useValue: '/'}
],
imports: [BrowserModule,HttpModule, RouterModule.forRoot([
{ path: '', component: PeopleComponent },
{ path: 'person/:id', component: PersonComponent }
])]
});
但是我最终得到以下错误......
inline template:0:0 caused by: Bootstrap at least one component before injecting Router.
如何在注入APP_BASE_HREF之前引导组件?如果我没有其他组件,例如我的应用程序中只有一个组件,那么它没有任何意义吗?