Here’s how to fix a few common Angular 2 unit test errors:
Fix: Import FormsModule.
import { FormsModule } from '@angular/forms';
imports: [
FormsModule
]
Fix: Import ReactiveFormsModule.
import {ReactiveFormsModule} from '@angular/forms';
imports: [
ReactiveFormsModule
]
Fix: Set the base href.
import {APP_BASE_HREF} from '@angular/common';
providers: [{provide: APP_BASE_HREF, useValue : '/' }]
Fix: Import HttpModule.
import {HttpModule} from '@angular/http';
imports: [
HttpModule
]
Fix: Import your routing file. In this case mine was called app.routes.
import {routing} from '../../app.routes';
imports: [
routing
],