Skip to content

Commit

Permalink
refactor(platform-server): reduce timeout used in tests
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
AndrewKushnir committed Dec 21, 2024
1 parent 8c5db3c commit bd51a7a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/platform-server/test/incremental_hydration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ function dynamicImportOf<T>(type: T, timeout = 0): Promise<T> {
* 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', () => {
Expand Down Expand Up @@ -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)];
};
},
};
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit bd51a7a

Please sign in to comment.