angular/packages/core/test
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
..
acceptance fix(core): afterNextRender hooks return that callback value. (#57031) 2024-07-19 13:40:59 -07:00
animation refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
authoring refactor(core): clean up clang comments and workarounds (#55750) 2024-05-13 11:10:36 -07:00
bundling fix(core): errors during ApplicationRef.tick should be rethrown for zoneless tests (#56993) 2024-07-29 13:49:00 -07:00
change_detection refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -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
di refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
dom refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -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: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
i18n refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
linker fix(core): link errors to ADEV (#55554) (#56038) 2024-05-28 12:50:53 +02:00
metadata refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
playground/zone-signal-input refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
reflection refactor(core): remove unused logic from reflection capabilities (#45335) 2022-03-24 11:02:39 -07:00
render3 fix(compiler): JIT mode incorrectly interpreting host directive configuration in partial compilation (#57002) 2024-07-16 08:37:26 -07:00
sanitization refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
signals refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
strict_types refactor(core): rename ...WithMeta types to ...Declaration and alias to unknown (#41119) 2021-03-22 08:57:18 -07:00
testability refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
util refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
zone refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
application_config_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
application_init_spec.ts fix(core): link errors to ADEV (#55554) (#56038) 2024-05-28 12:50:53 +02:00
application_module_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
application_ref_integration_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
application_ref_spec.ts fix(core): link errors to ADEV (#55554) (#56038) 2024-05-28 12:50:53 +02:00
BUILD.bazel test(core): Add scheduler in tests to tie into ApplicationRef.isStable (#53579) 2024-01-09 16:05:31 -08:00
change_detection_scheduler_spec.ts refactor(core): Update error for both zone and zoneless to be only for apps (#55813) 2024-05-15 13:27:26 -07:00
component_fixture_spec.ts fix(core): errors during ApplicationRef.tick should be rethrown for zoneless tests (#56993) 2024-07-29 13:49:00 -07:00
defer_fixture_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
dev_mode_spec.ts test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
directive_lifecycle_integration_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
error_handler_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
event_emitter_spec.ts fix(core): async EventEmitter should contribute to app stability (#56308) 2024-06-11 15:10:21 -07:00
fake_async_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
forward_ref_integration_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
runtime_error_spec.ts refactor(docs-infra): complete removal of aio directory (#56496) 2024-06-18 12:26:00 -07:00
test_bed_effect_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
test_bed_spec.ts refactor(core): handle incomplete DOCUMENT instances during cleanup in tests (#56422) 2024-06-17 09:05:52 -07:00
transfer_state_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
util_spec.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00