2

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?

keshavmurthy
  • 37
  • 1
  • 11
  • 1
    Did you import the modules relative to the CDK table ? –  Mar 20 '18 at 12:01
  • Yes I have included the CDK table but still it shows the same error – keshavmurthy Mar 20 '18 at 12:03
  • Then could you show us the declaration of your testbed ? –  Mar 20 '18 at 12:04
  • Also, I don't know about your Material version, but now it's `matHeaderRowDef`, not `cdkHeaderRowDef` –  Mar 20 '18 at 12:05
  • Testbed declaration is :: beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ TabledataComponent ], imports: [ RouterTestingModule, HttpModule ], providers: [ TestService ], schemas: [ CUSTOM_ELEMENTS_SCHEMA ] }).compileComponents(); })); – keshavmurthy Mar 20 '18 at 12:09
  • What about you edit your question instead ? –  Mar 20 '18 at 12:09
  • And you didn't import the module ... –  Mar 20 '18 at 12:09
  • After changing cdk to 'mat' this error is being showing [ERROR ->] – keshavmurthy Mar 20 '18 at 12:20
  • **STOP. POSTING. CODE. IN. COMMENTS.** And you didn't import the table module, I gave you an asnwer, try it. –  Mar 20 '18 at 12:21

1 Answers1

2

Import the table module into your testBed.

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