After running ng test
, my Angular 5 app keeps returning errors like
Can't bind to 'routerLink' since it isn't a known property of 'button'.
and
Can't bind to 'ngModel' since it isn't a known property of 'select'.
It was generated by Angular-CLI.
Going in to my app.component.spec.ts
file...
import { RouterTestingModule } from '@angular/router/testing'
import { AppComponent } from './app.component'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { UserService } from './user-account/user.service'
describe('AppComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule,
FormsModule,
ReactiveFormsModule
],
declarations: [
AppComponent
],
providers: [
UserService
]
})
TestBed.compileComponents()
})
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent)
const app = fixture.debugElement.componentInstance
expect(app).toBeTruthy()
}))
it(`should have as title 'app works!'`, async(() => {
const fixture = TestBed.createComponent(AppComponent)
const app = fixture.debugElement.componentInstance
expect(app.title).toEqual('app works!')
}))
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent)
fixture.detectChanges()
const compiled = fixture.debugElement.nativeElement
expect(compiled.querySelector('h1').textContent).toContain('app works!')
}))
})
Since I'm importing the FormsModule
and RouterTestingModule
, I shouldn't be seeing these errors, right? I've closed and re-ran the test after saving but that has not fixed it either.