Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it’s suited for websites, Node.js projects, or anywhere that JavaScript can run.
How to reproduce it
module.ts
import { ReactiveFormsModule } from '@angular/forms';
@NgModule({
declarations: [
...
],
imports: [
...
ReactiveFormsModule
]
})
component.specs.ts
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ... ]
})
.compileComponents();
fixture = TestBed.createComponent(...);
component = fixture.componentInstance;
fixture.detectChanges();
});
Error message
Error: NG0303: Can't bind to 'formGroup' since it isn't a known property of 'form' (used in the 'Component' component template).
1. If 'form' is an Angular component and it has the 'formGroup' input, then verify that it is a part of an @NgModule where this component is declared.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
Solution
Import ReactiveFormsModule.
component.specs.ts
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ...],
imports: [ ReactiveFormsModule ]
})
.compileComponents();
fixture = TestBed.createComponent(...);
component = fixture.componentInstance;
fixture.detectChanges();
});