angular/packages
Paul Gschwendtner 4e0cee52f0 fix(core): do not invoke jasmine done callback multiple times with waitForAsync
Currently tests written using `waitForAsync` would be prone to Jasmine
warnings or errors (depending on the version) for tests incorrectly
invoking asynchronous jasmine `done` callbacks multiple times.

This can happen because the async test zone logic schedules the
`done` callback to be called using `setTimeout`, but this could
be invoked multiple times, causing multiple `done` invocations to
be scheduled. Most of the issues have been resolved with #45025,
but it does not solve the case of multiple tasks finished and callbacks
being scheduled.

Technically, the current logic is built in way that _should_ result in
`_finishCallbackIfDone` and eventually the `done` callback to be invoked
at maximium once. This is unfortunately not the case in some rather
advanced/unexpected scenarios (like our AngularJS upgrade tests) where
the scenario is the following (and microtasks from before the actual
`waitForAsync` spec are still completing -- which is valid):

```
1. A test `beforeEach` schedules a microtask in the ProxyZone.
2. An actual empty `it` spec executes in the AsyncTestZone` (using e.g. `waitForAsync`).
3. The `onInvoke` invokes `_finishCallbackIfDone` because the spec runs synchronously.
4. We wait the scheduled timeout (see below) to account for unhandled promises.
5. The microtask from (1) finishes and `onHasTask` is invoked.

--> We register a second `_finishCallbackIfDone` even though we have scheduled a timeout.
--> we execute the `done` callback twice because the async zone spec state is "stable"
```
2022-07-18 19:19:00 +02:00
..
animations refactor(animations): refactor non-animatable check to be timeline based (#46666) 2022-07-12 22:36:22 +00:00
bazel build: update dependency @rollup/plugin-commonjs to v22 (#46556) 2022-06-29 10:08:29 -07:00
benchpress build: clean up references to old master branch (#45856) 2022-05-04 16:23:33 -07:00
common feat(core): alias createNgModuleRef as createNgModule (#46789) 2022-07-12 16:11:41 +00:00
compiler fix(compiler): inputs/outputs incorrectly parsed in jit mode (#46813) 2022-07-13 21:26:50 +00:00
compiler-cli fix(compiler-cli): only consider used pipes for inline type-check requirement (#46807) 2022-07-12 21:09:18 +00:00
core refactor(platform-browser): Updates keyboard event library to support code field (#46030) 2022-07-18 15:28:58 +00:00
docs docs: fix packages\docs\di\di.md (#46704) 2022-07-08 17:53:39 +00:00
elements feat(core): drop support for Node.js 12 (#45286) 2022-03-08 12:05:03 -08:00
examples refactor(core): drop all .ngfactory and .ngsummary imports (#44957) 2022-02-07 15:31:49 -08:00
forms feat(forms): add FormBuilder.record() method (#46485) 2022-07-15 22:02:44 +00:00
language-service fix(compiler-cli): only consider used pipes for inline type-check requirement (#46807) 2022-07-12 21:09:18 +00:00
localize docs: fix spelling (#46713) 2022-07-08 20:54:52 +00:00
misc/angular-in-memory-web-api build: update angular version of in-memory-web-api (#46344) 2022-06-13 17:40:09 +00:00
platform-browser refactor(platform-browser): Updates keyboard event library to support code field (#46030) 2022-07-18 15:28:58 +00:00
platform-browser-dynamic feat(bazel): speed up dev-turnaround by bundling types only when packaging (#45405) 2022-04-21 11:09:39 -07:00
platform-server feat(core): expose EnvironmentInjector on ApplicationRef (#46665) 2022-07-07 13:05:27 -07:00
private/testing test: add an internal helper to populate document.head before a test (#46250) 2022-06-06 16:12:32 -07:00
router fix(router): Ensure target RouterStateSnapshot is defined in NavigationError (#46842) 2022-07-14 22:19:26 +00:00
service-worker docs: fix spelling (#46713) 2022-07-08 20:54:52 +00:00
upgrade fix(compiler): inputs/outputs incorrectly parsed in jit mode (#46813) 2022-07-13 21:26:50 +00:00
zone.js fix(core): do not invoke jasmine done callback multiple times with waitForAsync 2022-07-18 19:19:00 +02:00
BUILD.bazel build: Auto-gen tsec tsconfig files (#43440) 2021-09-17 17:17:34 +00:00
circular-deps-test.conf.js refactor: replace deprecated String.prototype.substr() (#45397) 2022-03-24 11:48:09 -07:00
empty.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
goog.d.ts refactor(core): replace references to goog.LOCALE with goog.getLocale() (#43089) 2021-08-10 10:35:26 -07:00
license-banner.txt build: bump license year (#44590) 2022-01-04 12:05:25 -08:00
README.md docs: add doc reference to npm package readme (#33911) 2019-11-20 14:46:23 -08:00
system.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
tsconfig-build.json build: enable useUnknownInCatchVariables (#44679) 2022-02-01 18:17:29 +00:00
tsconfig-legacy-saucelabs.json build: bundle spec files for saucelabs legacy job (#44281) 2021-11-30 11:56:04 -05:00
tsconfig-test.json build: switch devmode output to es2015 (#44505) 2022-01-05 23:20:20 +00:00
tsconfig-tsec-base.json build: update tsconfigs to use ES2020 as target and module (#43431) 2021-10-01 18:28:42 +00:00
tsconfig.json build: enable useUnknownInCatchVariables (#44679) 2022-02-01 18:17:29 +00:00
tsec-exemption.json build: Enable tsec checks for critical packages. (#43108) 2021-09-13 14:45:57 -07: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