Skip to content

Commit 3d4ddd2

Browse files
committed
fix(core): Testing should not throw when Zone does not patch test FW APIs (angular#61628)
This prevents `core/testing` from throwing an error if ZoneJS is present but does not patch the test FW APIs such that `fakeAsync` works automatically. For example, there is currently no patching of the vitest APIs, so if you try to use Vitest with Zone on the page, it will throw. PR Close angular#61628
1 parent c895115 commit 3d4ddd2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/core/testing/src/fake_async.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function resetFakeAsyncZoneIfExists(): void {
5959
* @publicApi
6060
*/
6161
export function fakeAsync(fn: Function, options?: {flush?: boolean}): (...args: any[]) => any {
62-
if (fakeAsyncTestModule) {
62+
if (fakeAsyncTestModule && (Zone as any)['ProxyZoneSpec']?.isLoaded()) {
6363
return fakeAsyncTestModule.fakeAsync(fn, options);
6464
}
6565
throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);

0 commit comments

Comments
 (0)