angular/packages/core/testing/src
Andrew Scott dfcf0d5882 fix(core): afterRender hooks now only run on ApplicationRef.tick (#52455)
The `afterRender` hooks currently run after `ApplicationRef.tick` but
also run after any call to `ChangeDetectorRef.detectChanges`. This is
problematic because code which uses `afterRender` cannot expect the
component it's registered from to be rendered when the callback
executes. If there is a call to `ChangeDetectorRef.detectChanges` before
the global change detection, that will cause the hooks to run earlier
than expected.

This behavior is somewhat of a blocker for the zoneless project. There
is plenty of application code that do things like `setTimeout(() =>
doSomethingThatExpectsComponentToBeRendered())`, `NgZone.onStable(() =>
...)` or `ApplicationRef.onStable...`. `ApplicationRef.onStable` is a
should likely work similarly, but all of these are really wanting an API
that is `afterRender` with the requirement that the hook runs after the
global render, not an individual CDRef instance.

This change updates the `afterRender` hooks to only run when
`ApplicationRef.tick` happens.

fixes #52429
fixes #53232

PR Close #52455
2024-01-08 11:30:27 -08:00
..
async.ts feat(core): drop support for zone.js 0.10.x (#40823) 2021-02-24 07:58:29 -08:00
component_fixture.ts fix(core): afterRender hooks now only run on ApplicationRef.tick (#52455) 2024-01-08 11:30:27 -08:00
defer.ts refactor(core): ignore after and minimum when transition between states in tests (#52314) 2023-10-24 09:25:13 -07:00
fake_async.ts docs: fix typo (#49669) 2023-04-03 19:18:40 -07:00
logger.ts refactor(core): cleanup type any (#48623) 2023-01-04 12:15:16 -08:00
metadata_override.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
metadata_overrider.ts fix(core): support cyclic metadata in TestBed overrides (#44215) 2021-11-19 19:27:08 +00:00
resolvers.ts feat(core): support TypeScript 4.8 (#47038) 2022-08-16 16:02:47 +00:00
styling.ts refactor(core): drop IE workarounds (#49763) 2023-04-13 14:01:45 +00:00
test_bed.ts refactor(core): Run ComponentFixture constructor in injection context (#53400) 2023-12-07 09:35:24 -08:00
test_bed_common.ts refactor(core): Add defer block testing fixture (#51698) 2023-09-13 10:47:04 -07:00
test_bed_compiler.ts fix(core): avoid stale provider info when TestBed.overrideProvider is used (#52918) 2023-11-29 09:48:53 +01:00
test_hooks.ts fix(core): guard the jasmine hooks (#51394) 2023-08-21 08:14:53 -07:00
testing.ts refactor(core): Add defer block testing fixture (#51698) 2023-09-13 10:47:04 -07:00
testing_internal.ts refactor(core): Remove ununsed Zone mock from testing internals. (#49873) 2023-04-18 14:00:15 +00:00