Can't bind to 'matMenuTriggerFor' since it isn't a known property of 'button'
Can't bind to 'matMenuTriggerFor' since it isn't a known property of 'button'
I'm getting following error when I try to test an angular component:
Error while running jest tests:
Can't bind to 'matMenuTriggerFor' since it isn't a known property of 'button'.
Here is my html:
<button mat-button [matMenuTriggerFor]="menu">Menu</button>
<mat-menu #menu="matMenu">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>`
I'm using "@angular/material": "6.1.0", in my package.json.
I've also imported all the required material dependencies in the beforeAll block under TestBed
I also tried changing the property of the button from matMenuTriggerFor to mat-menu-trigger-for. It didn't work.
"@angular/material": "6.1.0",
beforeAll
TestBed
matMenuTriggerFor
mat-menu-trigger-for
Please suggest how can I fix this test.
2 Answers
2
Import MatMenuModule in your feature Module OR the Module where this component resides in.
MatMenuModule
import MatMenuModule from '@angular/material/menu';
and
imports: [
MatMenuModule
]
I think you need to add the MatMenuModule import to your app.module file.
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy