angular / angular/components

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

Offen
#14,375 12 Kommentare 29 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/table P4
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

#### 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`

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend, testing
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.