From 8af7d3a50b88bcd592aa8aff370ca63e3655c1b2 Mon Sep 17 00:00:00 2001 From: Doug Parker Date: Thu, 1 Feb 2024 19:59:39 -0800 Subject: [PATCH] refactor(zone.js): update Node test entry point to call patch functions (#53443) This executes the patches in the top-level scope of Node tests. PR Close #53443 --- packages/zone.js/test/node-env-setup.ts | 8 ++-- .../zone.js/test/node_entry_point.init.ts | 38 +++++++++++++------ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/packages/zone.js/test/node-env-setup.ts b/packages/zone.js/test/node-env-setup.ts index 0bf818bbc92..ce415f35dd4 100644 --- a/packages/zone.js/test/node-env-setup.ts +++ b/packages/zone.js/test/node-env-setup.ts @@ -1,3 +1,5 @@ -// Change default symbol prefix for testing to ensure no hard-coded references. -(global as any)['__Zone_symbol_prefix'] = '__zone_symbol_test__'; -(global as any)['__zone_symbol_test__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION'] = false; +export function setupNodeEnv(): void { + // Change default symbol prefix for testing to ensure no hard-coded references. + (global as any)['__Zone_symbol_prefix'] = '__zone_symbol_test__'; + (global as any)['__zone_symbol_test__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION'] = false; +} diff --git a/packages/zone.js/test/node_entry_point.init.ts b/packages/zone.js/test/node_entry_point.init.ts index fe3bc516caa..7b28f55ce0d 100644 --- a/packages/zone.js/test/node_entry_point.init.ts +++ b/packages/zone.js/test/node_entry_point.init.ts @@ -13,17 +13,31 @@ * found in the LICENSE file at https://angular.io/license */ -// Must be loaded before zone loads, so that zone can detect WTF. -import './node-env-setup'; -import './test_fake_polyfill'; -// Setup tests for Zone without microtask support -import '../lib/node/rollup-main'; -// Zone symbol prefix is set to '__zone_symbol2__' in node-env-setup.ts. import './test-env-setup-jasmine'; import './wtf_mock'; -import '../lib/testing/zone-testing'; -import '../lib/zone-spec/task-tracking'; -import '../lib/zone-spec/wtf'; -import '../lib/rxjs/rxjs'; -import '../lib/rxjs/rxjs-fake-async'; -import '../lib/jasmine/jasmine'; + +import {patchJasmine} from '../lib/jasmine/jasmine'; +import {rollupMain} from '../lib/node/main'; +import {patchRxJs} from '../lib/rxjs/rxjs'; +import {patchRxJsFakeAsync} from '../lib/rxjs/rxjs-fake-async'; +import {rollupTesting} from '../lib/testing/zone-testing'; +import {patchTaskTracking} from '../lib/zone-spec/task-tracking'; +import {patchWtf} from '../lib/zone-spec/wtf'; + +import {setupNodeEnv} from './node-env-setup'; +import {setupFakePolyfill} from './test_fake_polyfill'; + +// Must be loaded before zone loads, so that zone can detect WTF. +setupNodeEnv(); +setupFakePolyfill(); + +// Setup tests for Zone without microtask support +const Zone = rollupMain(); + +// Zone symbol prefix is set to '__zone_symbol2__' in node-env-setup.ts. +rollupTesting(Zone); +patchTaskTracking(Zone); +patchWtf(Zone); +patchRxJs(Zone); +patchRxJsFakeAsync(Zone); +patchJasmine(Zone);