angular / angular/components

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

Aperta
#14,375 12 commenti 29 reazioni 0 assegnatari Vedi su GitHub
area: material/table P4
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend, testing
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.