I have an Angular Material tab group on my page. I have to test changing of tabs using Cypress. When the page loads the user is on the Basic Information tab, I want to switch to the Relationships tab. I am not able to change the tabs
Here's the code:
<mat-tab-group animationDuration="0ms">
<mat-tab label="Basic Information">
</mat-tab>
<mat-tab data-cy="relationship-tab" label="Relationship" *ngIf="leiType.value===leiTypes.CORPORATION">
</mat-tab>
<mat-tab label="Address">
</mat-tab>
</mat-tab-group>
I am using the click event on the label to change the tab, but to no avail.
cy.get(`[data-cy='relationship-tab']`).click();
// cy.get(`[data-cy='relationship-tab']`).trigger('click');
I get the following error:
Timed out retrying: Expected to find element: [data-cy='relationship-tab'], but never found it.
I accomplished that by
cy.get('.mat-tab-label').contains('Relationship').click()