How to test mat-tree component?

Viewed 764

I'm using Angular 9 and I'm writing e2e tests using protractor. I want to select select something from a mat-tree component through my tests. For other material components I use harnesses but I don't think there is a harness for mat-tree. Any ideas? This is the html code I use for the tree.

<mat-tree [dataSource]="dataSource" [treeControl]="treeControl"
        class="example-tree">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle>
  <li class="mat-tree-node">
    <button (click)="saveValue(node.name)" mat-icon-button>{{node.name | translate}}</button>
  </li>
</mat-tree-node>
<mat-nested-tree-node *matTreeNodeDef="let node; when: hasChild">
  <li>
    <div class="mat-tree-node">
      <button mat-icon-button matTreeNodeToggle
              [attr.aria-label]="'toggle ' + node.name | translate">
        <mat-icon class="mat-icon-rtl-mirror">
          {{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
        </mat-icon>
        {{node.name | translate}}</button>

    </div>
    <ul [class.example-tree-invisible]="!treeControl.isExpanded(node)">
      <ng-container matTreeNodeOutlet></ng-container>
    </ul>
  </li>
</mat-nested-tree-node>

0 Answers
Related