From 19ec8266d1ef01ff59dfad55bc54e0f83bb87e67 Mon Sep 17 00:00:00 2001 From: Andrew Kushnir Date: Fri, 20 Dec 2024 17:22:23 -0800 Subject: [PATCH] refactor(platform-server): reduce timeout used in tests (#59275) This commit updates the timeout used in the incremental hydration tests from `101` -> `10` ms, which allows to speed up tests by ~20% (12.5 -> 10 seconds locally). PR Close #59275 --- .../test/incremental_hydration_spec.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/platform-server/test/incremental_hydration_spec.ts b/packages/platform-server/test/incremental_hydration_spec.ts index 44e0c8b4665..9b720c17397 100644 --- a/packages/platform-server/test/incremental_hydration_spec.ts +++ b/packages/platform-server/test/incremental_hydration_spec.ts @@ -65,8 +65,8 @@ function dynamicImportOf(type: T, timeout = 0): Promise { * Helper function to await all pending dynamic imports * emulated using `dynamicImportOf` function. */ -function allPendingDynamicImports() { - return dynamicImportOf(null, 101); +function allPendingDynamicImports(timeout?: number) { + return dynamicImportOf(null, timeout ?? 10); } describe('platform-server partial hydration integration', () => { @@ -2364,10 +2364,12 @@ describe('platform-server partial hydration integration', () => { location = inject(Location); } + const dynamicImportTimeout = 5; // ms + const deferDepsInterceptor = { intercept() { return () => { - return [dynamicImportOf(DeferredCmp, 100)]; + return [dynamicImportOf(DeferredCmp, dynamicImportTimeout)]; }; }, }; @@ -2397,10 +2399,12 @@ describe('platform-server partial hydration integration', () => { const routeLink = doc.getElementById('route-link')!; routeLink.click(); - await allPendingDynamicImports(); + // Wait a bit longer than a timeout used to emulate a dynamic import. + await allPendingDynamicImports(dynamicImportTimeout * 2); appRef.tick(); - await allPendingDynamicImports(); + // Wait a bit longer than a timeout used to emulate a dynamic import. + await allPendingDynamicImports(dynamicImportTimeout * 2); await appRef.whenStable(); expect(location.path()).toBe('/other/thing/stuff');