Skip to content

Commit ab12e4f

Browse files
committed
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.
1 parent 359d74c commit ab12e4f

4 files changed

Lines changed: 20 additions & 15 deletions

File tree

‎tests/e2e.bzl‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None):
151151
args = []
152152
tests = None
153153
ignore = None
154+
shard_count = TEST_SHARD_COUNT
154155

155156
if toolchain_name:
156157
toolchain_name = "_" + toolchain_name
@@ -168,6 +169,7 @@ def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None):
168169
args.append("--esbuild")
169170
tests = BROWSER_TESTS
170171
ignore = None
172+
shard_count = 1
171173
elif type == "webpack":
172174
tests = None
173175
ignore = BROWSER_TESTS + WEBPACK_IGNORE_TESTS
@@ -179,7 +181,7 @@ def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None):
179181
size = "enormous",
180182
data = data,
181183
toolchain = toolchain,
182-
shard_count = TEST_SHARD_COUNT,
184+
shard_count = shard_count,
183185
templated_args = args + [
184186
"--glob=%s" % _to_glob(tests) if tests else "",
185187
"--ignore=%s" % _to_glob(ignore) if ignore else "",
@@ -193,7 +195,7 @@ def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None):
193195
size = "enormous",
194196
data = data,
195197
toolchain = toolchain,
196-
shard_count = TEST_SHARD_COUNT,
198+
shard_count = shard_count,
197199
templated_args = args + [
198200
"--ng-snapshots",
199201
"--glob=%s" % _to_glob(tests) if tests else "",

‎tests/e2e/tests/misc/browsers.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import express from 'express';
2-
import * as path from 'node:path';
2+
import path from 'node:path';
33
import { copyProjectAsset } from '../../utils/assets';
44
import { appendToFile, createDir, replaceInFile, writeFile } from '../../utils/fs';
55
import { exec, ng } from '../../utils/process';
@@ -21,9 +21,7 @@ export default async function () {
2121
throw new Error('SauceLabs is not configured.');
2222
}
2323

24-
for (const e2eDep of E2E_DEV_DEPENDENCIES) {
25-
await installPackage(e2eDep);
26-
}
24+
await installPackage(E2E_DEV_DEPENDENCIES);
2725

2826
await appendToFile(
2927
'src/app/app.config.ts',

‎tests/e2e/utils/packages.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getGlobalVariable } from './env';
2-
import { ProcessOutput, silentBun, silentNpm, silentPnpm, silentYarn } from './process';
2+
import { type ProcessOutput, silentBun, silentNpm, silentPnpm, silentYarn } from './process';
33

44
export interface PkgInfo {
55
readonly name: string;
@@ -32,17 +32,22 @@ export async function installWorkspacePackages(options?: { force?: boolean }): P
3232
}
3333
}
3434

35-
export function installPackage(specifier: string, registry?: string): Promise<ProcessOutput> {
35+
export function installPackage(
36+
specifier: string | string[],
37+
registry?: string,
38+
): Promise<ProcessOutput> {
3639
const registryOption = registry ? [`--registry=${registry}`] : [];
40+
const specifiers = Array.isArray(specifier) ? specifier : [specifier];
41+
3742
switch (getActivePackageManager()) {
3843
case 'npm':
39-
return silentNpm('install', specifier, ...registryOption);
44+
return silentNpm('install', ...specifiers, ...registryOption);
4045
case 'yarn':
41-
return silentYarn('add', specifier, ...registryOption);
46+
return silentYarn('add', ...specifiers, ...registryOption);
4247
case 'bun':
43-
return silentBun('add', specifier, ...registryOption);
48+
return silentBun('add', ...specifiers, ...registryOption);
4449
case 'pnpm':
45-
return silentPnpm('add', specifier, ...registryOption);
50+
return silentPnpm('add', ...specifiers, ...registryOption);
4651
}
4752
}
4853

‎tests/e2e/utils/test_process.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ const testFunction: () => Promise<void> | void =
1111
throw new Error('Invalid test module.');
1212
};
1313

14-
// 4-minute timeout to prevent hanging tests from blocking the runner indefinitely.
15-
const TEST_TIMEOUT_MS = 4 * 60 * 1000;
14+
// 8-minute timeout to prevent hanging tests from blocking the runner indefinitely.
15+
const TEST_TIMEOUT_MS = 8 * 60 * 1000;
1616

1717
(async () => {
1818
let timeoutId: NodeJS.Timeout | undefined;
1919
try {
2020
const timeoutPromise = new Promise<never>((_, reject) => {
2121
timeoutId = setTimeout(() => {
22-
reject(new Error(`Test "${testScript}" timed out after 4 minutes.`));
22+
reject(new Error(`Test "${testScript}" timed out after 8 minutes.`));
2323
}, TEST_TIMEOUT_MS);
2424
});
2525

0 commit comments

Comments
 (0)