angular/packages/core/src
Andrew Scott 3a63c9ebbe fix(core): errors during ApplicationRef.tick should be rethrown for zoneless tests (#56993)
The behavior of `ComponentFixture` for zoneless tests was decided somewhat through guesswork, trial, and error. In addition, working on the zoneless fixture revealed oddities in the behavior of the zone-based fixture, or behaviors that we felt were counterintuitive. The most consequential difference is how change detection works: `detectChanges` goes through ApplicationRef.tick in zoneless while it is `changeDetectorRef.detectChanges` in the zone fixture.

We felt that running change detection through `ApplicationRef.tick` was important for several reasons:
* Aligning application behavior more closely with the test behavior (almost all views are attached to application ref in reality)
* Ensuring that afterRender* hooks are executed when calling `fixture.detectChanges`
* Ensuring that the change detection runs again if render hooks update state

This change, however, has some noticeable consequences that will break some tests, mostly around how errors are handled. `ApplicationRef.tick` catches errors that happen during change detection and reports them to the ErrorHandler from DI. The default error handler only logs the error to the console. This will break tests which have `expect(() => fixture.detectChanges()).toThrow()`. In addition, it allows tests to pass when there are real errors encountered during change detection.

This change ensures that errors from `ApplicationRef.tick` are rethrown
and will fail the test. We should also do a follow-up investigation to
determine whether we can/should also do this for the zone-based
`ComponentFixture`.

fixes #56977

PR Close #56993
2024-07-29 13:49:00 -07:00
..
application fix(core): Deprecate ignoreChangesOutsideZone option (#57029) 2024-07-23 10:10:48 -07:00
authoring refactor(core): ModelSignal should extend InputSignal (#56452) 2024-06-17 08:59:58 -07:00
change_detection fix(core): errors during ApplicationRef.tick should be rethrown for zoneless tests (#56993) 2024-07-29 13:49:00 -07:00
compiler refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
debug refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
defer fix(core): establish proper defer injector hierarchy for components attached to ApplicationRef (#56763) 2024-07-03 14:08:43 +00:00
di refactor(core): integrate let instructions into the runtime (#56527) 2024-06-26 08:48:31 -07:00
event_dispatch refactor(core): Allow manual renderer listens to contribute to event delegation as well. (#56799) 2024-07-19 13:42:26 -07:00
hydration refactor(core): Move logic into early event contract files. (#56994) 2024-07-18 12:05:17 -07:00
i18n refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
interface refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
linker feat(core): expose signal input metadata in ComponentMirror (#56402) 2024-06-13 10:12:06 -07:00
metadata refactor(core): deprecate @Component.interpolation (#55778) 2024-05-14 11:48:12 -07:00
platform refactor(core): Remove hybrid mode flag and move scheduler provider location (#55722) 2024-05-23 18:15:53 +02:00
reflection refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
render refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
render3 fix(core): afterNextRender hooks return that callback value. (#57031) 2024-07-19 13:40:59 -07:00
sanitization refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
testability refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
util refactor(core): Update coalescing to just use patched timers in root zone (#55366) 2024-05-02 14:43:10 -07:00
view refactor: remove unnecessary file (#49042) 2023-02-17 11:08:33 -08:00
zone refactor(core): Update coalescing to just use patched timers in root zone (#55366) 2024-05-02 14:43:10 -07:00
authoring.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
cached_injector_service.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
change_detection.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
console.ts refactor(core): make platform core providers tree-shakable (#45506) 2022-04-12 22:28:23 +00:00
core.externs.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
core.ts fix(core): Add back phase flag option as a deprecated API (#55648) 2024-06-10 13:53:39 -07:00
core_private_export.ts fix(core): errors during ApplicationRef.tick should be rethrown for zoneless tests (#56993) 2024-07-29 13:49:00 -07:00
core_reactivity_export.ts feat(core): add Angular Signals to the public API (#49150) 2023-02-22 11:27:21 -08:00
core_reactivity_export_internal.ts refactor(core): clean up clang comments and workarounds (#55750) 2024-05-13 11:10:36 -07:00
core_render3_private_export.ts refactor(compiler): integrate let declarations into the template pipeline (#56299) 2024-06-20 08:48:52 -07:00
di.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
error_details_base_url.ts fix(core): link errors to ADEV (#55554) (#56038) 2024-05-28 12:50:53 +02:00
error_handler.ts fix(core): errors during ApplicationRef.tick should be rethrown for zoneless tests (#56993) 2024-07-29 13:49:00 -07:00
errors.ts refactor(core): integrate let instructions into the runtime (#56527) 2024-06-26 08:48:31 -07:00
event_delegation_utils.ts refactor(core): Allow manual renderer listens to contribute to event delegation as well. (#56799) 2024-07-19 13:42:26 -07:00
event_emitter.ts refactor(core): inject PendingTasks as optional in EventEmitter class (#56411) 2024-06-12 13:10:40 -07:00
image_performance_warning.ts fix(core): link errors to ADEV (#55554) (#56038) 2024-05-28 12:50:53 +02:00
linker.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
metadata.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
pending_tasks.ts fix(core): async EventEmitter should contribute to app stability (#56308) 2024-06-11 15:10:21 -07:00
r3_symbols.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
render.ts refactor(core): clean up circular dependencies (#39722) 2020-11-18 09:15:29 -08:00
transfer_state.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
version.ts fix(core): avoid repeated work when parsing version (#53598) 2023-12-18 16:26:36 +00:00
zone.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00