table[mat-table] doesn't allow debugElement.query to find directives inside it
See original GitHub issueBug, 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, <mat-table>
works OK, the problem seems to be on how <table mat-table>
renders the rows which seems to be with createEmbeddedView
Issue Analytics
- State:
- Created 5 years ago
- Reactions:29
- Comments:12 (2 by maintainers)
Top GitHub Comments
Still not fixed (8.0.0). It blocks any real tests. I have other components inside cell’s and I need test if there are where they should and if they have input values as expected. Can not do it without debugElement.
Any hopes for fixing it? It is 6 months old bug.
I spent some time looking into this and I’ve come out a bit puzzled on why this is happening. There are very few differences between
<table mat-table>
and<mat-table>
, so I suspect it may be related to_applyNativeTableSections
as mentioend by @jtxyz. I wish I could spend more time on it to find the root cause, but we’re a tight on resources and have a few higher priority things we need to focus on. It would be extremely helpful in someone in the community could spend some time looking into it.