I am trying to run a unit test which is testing a component with an injected router. This is my set up code...
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 }
])]
});
However I end up with the following error...
inline template:0:0 caused by: Bootstrap at least one component before injecting Router.
How do I bootstrap the component before injecting the APP_BASE_HREF ? It doesn't make any sense what if I don't have another component, for example if I had only one component in my app?