I get an error while running npm test
Can't bind to 'errorStateMatcher' since it isn't a known property of 'input'. ("dth">
<input matInput placeholder="Product Name" formControlName="prod_name"
[ERROR ->][errorStateMatcher]="matcher">
My Spec file is as follows
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { ProductAddComponent } from './product-add.component';
import { FormControl, FormGroupDirective, FormBuilder, FormGroup, NgForm, Validators } from '@angular/forms';
describe('ProductAddComponent', () => {
let component: ProductAddComponent;
let fixture: ComponentFixture<ProductAddComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule, ReactiveFormsModule],
declarations: [ ProductAddComponent ],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ProductAddComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
How do I provide errorStateMatcher
to test unit?
I think you need to import MatInputModule.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With