I am using the material angular tab nav list component in my application, it's working as expected but while executing the test case throws error.
Html:
<nav mat-tab-nav-bar>
<a mat-tab-link
*ngFor="let tab of tabs"
[routerLink]="tab.path"
routerLinkActive #rla="routerLinkActive"
[active]="rla.isActive"
selectedIndex="0" >
<i class="{鈥寋tab.icon}}"></i>
{鈥寋 tab.label }}
</a>
</nav>
Error Message:
There is no directive with "exportAs" set to "routerLinkActive" (" *ngFor="let tab of tabs"
[routerLink]="tab.path"
routerLinkActive [ERROR ->]#rla="routerLinkActive"
[active]="rla.isActive"
selectedIndex="0"
May I know why this error on only spec.
The routerLinkActive directive is defined in the RouterModule. You probably forgot to include it in your testing module, which is why it ends up throwing.
Worked after importing RouterTestingModule not with RouterModule.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Worked after importing RouterTestingModule not with RouterModule.
Reference: https://stackoverflow.com/questions/45159960/angular-4-error-no-provider-for-childrenoutletcontexts-in-karma-jasmine-test