From a8fc9a71728475ec28f2160a2758b7232eee842d Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Fri, 13 Nov 2026 09:55:34 +0000 Subject: [PATCH] test: prevent SauceLabs browser E2E test timeout and disable unused shards Batch devDependency installation in `tests/misc/browsers.ts`, increase per-test process timeout from 4 to 8 minutes to accommodate sequential SauceLabs browser sessions, and set `shard_count = 1` for the saucelabs suite. --- tests/e2e.bzl | 6 ++++-- tests/e2e/tests/misc/browsers.ts | 6 ++---- tests/e2e/utils/packages.ts | 17 +++++++++++------ tests/e2e/utils/test_process.ts | 6 +++--- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/e2e.bzl b/tests/e2e.bzl index 6ff420ac176c..1923d6e9ea42 100644 --- a/tests/e2e.bzl +++ b/tests/e2e.bzl @@ -151,6 +151,7 @@ def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None): args = [] tests = None ignore = None + shard_count = TEST_SHARD_COUNT if toolchain_name: toolchain_name = "_" + toolchain_name @@ -168,6 +169,7 @@ def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None): args.append("--esbuild") tests = BROWSER_TESTS ignore = None + shard_count = 1 elif type == "webpack": tests = None ignore = BROWSER_TESTS + WEBPACK_IGNORE_TESTS @@ -179,7 +181,7 @@ def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None): size = "enormous", data = data, toolchain = toolchain, - shard_count = TEST_SHARD_COUNT, + shard_count = shard_count, templated_args = args + [ "--glob=%s" % _to_glob(tests) if tests else "", "--ignore=%s" % _to_glob(ignore) if ignore else "", @@ -193,7 +195,7 @@ def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None): size = "enormous", data = data, toolchain = toolchain, - shard_count = TEST_SHARD_COUNT, + shard_count = shard_count, templated_args = args + [ "--ng-snapshots", "--glob=%s" % _to_glob(tests) if tests else "", diff --git a/tests/e2e/tests/misc/browsers.ts b/tests/e2e/tests/misc/browsers.ts index 1212013a2c99..d91258b95345 100644 --- a/tests/e2e/tests/misc/browsers.ts +++ b/tests/e2e/tests/misc/browsers.ts @@ -1,5 +1,5 @@ import express from 'express'; -import * as path from 'node:path'; +import path from 'node:path'; import { copyProjectAsset } from '../../utils/assets'; import { appendToFile, createDir, replaceInFile, writeFile } from '../../utils/fs'; import { exec, ng } from '../../utils/process'; @@ -21,9 +21,7 @@ export default async function () { throw new Error('SauceLabs is not configured.'); } - for (const e2eDep of E2E_DEV_DEPENDENCIES) { - await installPackage(e2eDep); - } + await installPackage(E2E_DEV_DEPENDENCIES); await appendToFile( 'src/app/app.config.ts', diff --git a/tests/e2e/utils/packages.ts b/tests/e2e/utils/packages.ts index 087d771f14b8..407f0f1d8573 100644 --- a/tests/e2e/utils/packages.ts +++ b/tests/e2e/utils/packages.ts @@ -1,5 +1,5 @@ import { getGlobalVariable } from './env'; -import { ProcessOutput, silentBun, silentNpm, silentPnpm, silentYarn } from './process'; +import { type ProcessOutput, silentBun, silentNpm, silentPnpm, silentYarn } from './process'; export interface PkgInfo { readonly name: string; @@ -32,17 +32,22 @@ export async function installWorkspacePackages(options?: { force?: boolean }): P } } -export function installPackage(specifier: string, registry?: string): Promise { +export function installPackage( + specifier: string | string[], + registry?: string, +): Promise { const registryOption = registry ? [`--registry=${registry}`] : []; + const specifiers = Array.isArray(specifier) ? specifier : [specifier]; + switch (getActivePackageManager()) { case 'npm': - return silentNpm('install', specifier, ...registryOption); + return silentNpm('install', ...specifiers, ...registryOption); case 'yarn': - return silentYarn('add', specifier, ...registryOption); + return silentYarn('add', ...specifiers, ...registryOption); case 'bun': - return silentBun('add', specifier, ...registryOption); + return silentBun('add', ...specifiers, ...registryOption); case 'pnpm': - return silentPnpm('add', specifier, ...registryOption); + return silentPnpm('add', ...specifiers, ...registryOption); } } diff --git a/tests/e2e/utils/test_process.ts b/tests/e2e/utils/test_process.ts index 2d767185f465..eda6677b5912 100644 --- a/tests/e2e/utils/test_process.ts +++ b/tests/e2e/utils/test_process.ts @@ -11,15 +11,15 @@ const testFunction: () => Promise | void = throw new Error('Invalid test module.'); }; -// 4-minute timeout to prevent hanging tests from blocking the runner indefinitely. -const TEST_TIMEOUT_MS = 4 * 60 * 1000; +// 8-minute timeout to prevent hanging tests from blocking the runner indefinitely. +const TEST_TIMEOUT_MS = 8 * 60 * 1000; (async () => { let timeoutId: NodeJS.Timeout | undefined; try { const timeoutPromise = new Promise((_, reject) => { timeoutId = setTimeout(() => { - reject(new Error(`Test "${testScript}" timed out after 4 minutes.`)); + reject(new Error(`Test "${testScript}" timed out after 8 minutes.`)); }, TEST_TIMEOUT_MS); });