angular-docs-cn/packages/core/testing/src
Kristiyan Kostadinov 0f23f7343e fix(core): error in TestBed if module is reset mid-compilation in ViewEngine (#42669)
When `TestBed.compileComponents` is called under ViewEngine, we kick off a compilation and return a promise that resolves once the compilation is done. In most cases the consumer doesn't _have_ to await the returned promise, unless their components have external resources.

The problem is that the test could be over by the time the promise has resolved, in which case we still cache the factory of the test module. This becomes a problem if another compilation is triggered right afterwards, because it'll see that we still have a `_moduleFactory` and it won't recreate the factory.

These changes resolve the issue by saving a reference to the module type that is being compiled and checking against it when the promise resolves.

Note that while this problem was discovered while trying to roll out the new test module teardown behavior in the Components repo (https://github.com/angular/components/pull/23070), it has been there for a long time. The new test behavior made it more apparent.

PR Close #42669
2021-06-30 14:32:23 -07: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 build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
fake_async.ts docs: edit copy for tick() in testing and api docs (#35697) 2021-05-25 18:03:32 +00:00
lang_utils.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
logger.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
metadata_override.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
metadata_overrider.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
ng_zone_mock.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
private_export_testing.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
r3_test_bed.ts feat(core): add opt-in test module teardown configuration (#42566) 2021-06-17 18:03:47 +00:00
r3_test_bed_compiler.ts refactor(core): rename `ɵɵInjectableDef` interface to `ɵɵInjectableDeclaration` (#41316) 2021-04-07 13:57:12 -07:00
resolvers.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
styling.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test_bed.ts fix(core): error in TestBed if module is reset mid-compilation in ViewEngine (#42669) 2021-06-30 14:32:23 -07:00
test_bed_common.ts feat(core): add opt-in test module teardown configuration (#42566) 2021-06-17 18:03:47 +00:00
test_compiler.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test_hooks.ts feat(core): add opt-in test module teardown configuration (#42566) 2021-06-17 18:03:47 +00:00
testing.ts feat(core): add opt-in test module teardown configuration (#42566) 2021-06-17 18:03:47 +00:00
testing_internal.ts test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00