angular / angular/components

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

Abierto
#14,375 12 comentarios 29 reacciones 0 asignados Ver en GitHub
area: material/table P4
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
frontend, testing
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.