In unit test, view children are populated after afterNextRender callback is called rather than before #57313
Labels
area: testing
Issues related to Angular testing features, such as TestBed
area: zones
P2
The issue is important to a large percentage of users, with a workaround
Milestone
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Given the following component:
I expect that clicking the button will make the input appear and give it the focus. And it indeed does that, but not in a unit test.
When running the following unit test, all the expectations pass except the last one, and the console logs show that the length of the view children inside the
afterNextRendercallback is 0.The same problem occurs with
@ViewChildrenorviewChildis being used.Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-kkjfwf?file=repro%2Fsrc%2Fapp%2Fapp.component.spec.ts,repro%2Fsrc%2Fapp%2Fapp.component.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version)Anything else?
To run the repro, here are the commands to run in the terminal:
The text was updated successfully, but these errors were encountered: