angular / angular/components

table[mat-table] doesn't allow debugElement.query to find directives inside it

オープン
#14,375 コメント 12 件 リアクション 29 件 担当者 0 名 GitHub で見る
area: material/table P4
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

#### Bug, feature request, or proposal:
Bug: `table[mat-table]` makes testing hard because it doesn't have a way for getting `debugElement`s to be queried.

#### What is the expected behavior?
`fixture.debugElement.query(By.css('*'))` should find directives inside a mat-table

#### What is the current behavior?
`fixture.debugElement.query(By.css('*'))` only finds `table[mat-table]` as a DebugElement but it can't find any other debug element that's a child of the table

#### What are the steps to reproduce?
https://stackblitz.com/edit/angular-testing-template-4n6yno
This has 2 describes: 1 with `table[mat-table]` (normal table) and another with `mat-table` (flex tables)

#### What is the use-case or motivation for changing an existing behavior?
Testing is hard otherwise, my work around has been overriding the module, remove the directive, make a fake directive that has `@HostBinding('click') click() { capturedInstance = this; }` and test with that.

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
6.0.0

#### Is there anything else we should know?
As implicitly mentioned above, `` works OK, the problem seems to be on how `` renders the rows which seems to be with `createEmbeddedView`

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start with the linked StackBlitz reproduction and compare the two describes for table[mat-table] and mat-table. Trace how the table renders rows through createEmbeddedView and verify whether fixture.debugElement.query(By.css('*')) can reach child elements. Done means the normal table exposes its child DebugElements while the existing mat-table case still works.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend, testing
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。