Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't bind to 'errorStateMatcher' since it isn't a known property of 'input'

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?

like image 837
Ulterior Avatar asked Nov 16 '18 14:11

Ulterior


Video Answer


1 Answers

I think you need to import MatInputModule.

like image 101
Bogdan Avatar answered Sep 22 '22 19:09

Bogdan