angular/packages
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
..
animations docs(docs-infra): Use shiki for code highlighting (#57059) 2024-07-24 10:24:51 -07:00
bazel refactor(docs-infra): complete removal of aio directory (#56496) 2024-06-18 12:26:00 -07:00
benchpress refactor(docs-infra): complete removal of aio directory (#56496) 2024-06-18 12:26:00 -07:00
common fix(common): Don't run preconnect assertion on the server. (#56213) 2024-07-16 09:53:33 -07:00
compiler fix(compiler): reduce chance of conflicts between generated factory and local variables (#57181) 2024-07-29 13:46:48 -07:00
compiler-cli fix(compiler): reduce chance of conflicts between generated factory and local variables (#57181) 2024-07-29 13:46:48 -07:00
core fix(core): errors during ApplicationRef.tick should be rethrown for zoneless tests (#56993) 2024-07-29 13:49:00 -07:00
docs/di docs: remove outdated/unsupported webworker doc (#49856) 2023-04-17 14:01:41 +00:00
elements refactor(docs-infra): complete removal of aio directory (#56496) 2024-06-18 12:26:00 -07:00
examples refactor: migrate docs, examples, private, service worker and upgrade to prettier formatting (#54163) 2024-01-30 20:08:40 +00:00
forms refactor(forms): Update status, touched, and pristine to use private setter (#56573) 2024-06-26 08:47:39 -07:00
language-service fix(compiler-cli): add warning for unused let declarations (#57033) 2024-07-23 08:27:17 -07:00
localize build: update babel dependencies (#57045) 2024-07-19 13:46:00 -07:00
misc/angular-in-memory-web-api build: bump in-memory-web-api to v18 (#56018) 2024-05-23 12:00:29 +02:00
platform-browser refactor(core): Add global event delegation provider (#56247) 2024-06-27 14:24:47 +00:00
platform-browser-dynamic refactor(docs-infra): complete removal of aio directory (#56496) 2024-06-18 12:26:00 -07:00
platform-server refactor(core): Refactor EarlyEventContract to prepare for using it as a container. (#56900) 2024-07-10 13:53:03 -07:00
private/testing refactor(docs-infra): remove reliance on aio example macro (#56496) 2024-06-18 12:25:59 -07:00
router Revert "fix(router): Scroller should scroll as soon as change detection completes (#55105)" (#57115) 2024-07-24 10:04:38 -07:00
service-worker docs: update broken link to version updates in versionEvent (#56870) (#56870) 2024-07-19 13:41:54 -07:00
upgrade refactor(docs-infra): complete removal of aio directory (#56496) 2024-06-18 12:26:00 -07:00
zone.js docs: fix changelog entry (#57038) 2024-07-18 11:12:29 -07:00
BUILD.bazel docs: Expose $localize in the @angular/localize/init entry. (#55345) 2024-07-16 08:43:52 -07:00
circular-deps-test.conf.js ci: complete migration to prettier formatting (#55580) 2024-04-29 14:00:16 -07:00
empty.ts
goog.d.ts
license-banner.txt build: update licence date. (#55129) 2024-04-08 11:31:12 -07:00
README.md
system.d.ts
tsconfig-build.json build: align with internal tsconfig options (#51728) 2023-09-12 11:39:42 -07:00
tsconfig-legacy-saucelabs.json feat(core): support TypeScript 5.5 (#56096) 2024-05-29 15:33:33 +02:00
tsconfig-test.json build: switch devmode output to es2015 (#44505) 2022-01-05 23:20:20 +00:00
tsconfig-tsec-base.json refactor(core): throw an error when hydration marker is missing from DOM (#51170) 2023-08-04 11:31:49 -04:00
tsconfig.json refactor(router): Update integration tests to cover navigation and history API (#53799) 2024-01-30 15:04:02 +00:00
tsec-exemption.json fix(core): hardening attribute and property binding rules for <iframe> elements (#47964) 2022-11-09 00:47:56 -08:00
types.d.ts build: update to jasmine 4.0 (#45558) 2022-04-11 16:25:28 +00:00

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT