I am running tests for my Angular app and encountered error Can't bind to 'routerLink' since it isn't a known property of 'a'
as well.
I thought it might be useful to show my Angular dependencies:
"@angular/animations": "^8.2.14",
"@angular/common": "^8.2.14",
"@angular/compiler": "^8.2.14",
"@angular/core": "^8.2.14",
"@angular/forms": "^8.2.14",
"@angular/router": "^8.2.14",
The issue was in my spec
file. I compared to another similar component spec
file and found that I was missing RouterTestingModule
in imports
, e.g.
TestBed.configureTestingModule({
declarations: [
...
],
imports: [ReactiveFormsModule, HttpClientTestingModule, RouterTestingModule],
providers: [...]
});
});