From 435a28e93745a3f7d4526e4cc8e279eaaacc3a96 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 23 Jun 2020 09:51:14 +0900 Subject: [PATCH] fix(core): fake_async_fallback should have the same logic with fake-async (#37680) PR https://github.com/angular/angular/pull/37523 failed when trying to use `rxjs delay` operator inside `fakeAsync`, and the reasons are: 1. we need to import `rxjs-fake-async` patch to make the integration work. 2. since in `angular` repo, the bazel target `/tools/testing:node` not using `zone-testing` bundle, instead it load `zone-spec` packages seperately, so it causes one issue which is the `zone.js/testing/fake-async` package is not loaded, we do have a fallback logic under `packages/core/testing` calles `fake_async_fallback`, but the logic is out of date with `fake-async` under `zone.js` package. So this PR, I updated the content of `fake_async_fallback` to make it consistent with `fake-async`. And I will make another PR to try to remove the `fallback` logic. PR Close #37680 --- packages/core/testing/src/fake_async_fallback.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/testing/src/fake_async_fallback.ts b/packages/core/testing/src/fake_async_fallback.ts index 2ff6bf358a..6026708ece 100644 --- a/packages/core/testing/src/fake_async_fallback.ts +++ b/packages/core/testing/src/fake_async_fallback.ts @@ -27,6 +27,9 @@ let _fakeAsyncTestZoneSpec: any = null; * @publicApi */ export function resetFakeAsyncZoneFallback() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } _fakeAsyncTestZoneSpec = null; // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); @@ -73,6 +76,7 @@ export function fakeAsyncFallback(fn: Function): (...args: any[]) => any { let res: any; const lastProxyZoneSpec = proxyZoneSpec.getDelegate(); proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); try { res = fn.apply(this, args); flushMicrotasksFallback();