Search code examples
angularjasmineangular-unit-test

Angular 4 unit testing template parse errors:


I am getting the following error when I run angular unit test using Jasmine.

Error: Template parse errors: Property binding cdkHeaderRowDef not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". (" [ERROR ->]

<mat-header-row *cdkHeaderRowDef="displayedColumns"></mat-header-row>
[ERROR ->]<mat-row *cdkRowDef="let row; columns: displayedColumns; let i = index; let isOdd = odd; let isEven ="): ng:///DynamicTestModule/TabledataComponent.html@57:4

Its looks like material design parsing error. Please suggest me what would be the issue?


Solution

  • Import the table module into your testBed.

    beforeEach(async(() => {
      TestBed.configureTestingModule({
        declarations: [TabledataComponent],
        imports: [RouterTestingModule, HttpModule, MatTableModule],
        providers: [RaindanceServiceService],
        schemas: [CUSTOM_ELEMENTS_SCHEMA]
      }).compileComponents();
    }));