fix(frontend-tests): expand test files in run-tests.mjs so Node 20 still runs the suite (BUG-1230)
Independent Staging Quality Gate / validate (push) Successful in 26m0s
Independent Staging Quality Gate / publish (push) Successful in 5m15s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
This commit is contained in:
Jesse_Chen
2026-10-04 23:22:08 +08:00
co-authored by Claude Opus 5.5
parent 2c64b66423
commit 1252de3e63
2 changed files with 20 additions and 4 deletions
+12 -4
View File
@@ -10,14 +10,22 @@
* The process exit code is the test runner's exit code (BUG-995).
*/
import { spawn } from "node:child_process";
import { mkdirSync, readFileSync } from "node:fs";
import { mkdirSync, readFileSync, readdirSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const frontendDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const repoRoot = path.resolve(frontendDir, "..");
const tsxCli = path.join(frontendDir, "node_modules", "tsx", "dist", "cli.mjs");
const testGlobs = ["tests/*.test.ts", "tests/*.test.tsx"];
// Expanded here instead of handing `tests/*.test.ts` to `node --test`: Node 20
// does not expand test globs ("Could not find tests/*.test.ts"), while the old
// `tsx --test tests/*.test.ts tests/*.test.tsx` script relied on the shell. Same
// order as the shell: every *.test.ts sorted, then every *.test.tsx sorted.
function testFiles() {
const names = readdirSync(path.join(frontendDir, "tests"));
const pick = (suffix) => names.filter((name) => name.endsWith(suffix)).sort().map((name) => `tests/${name}`);
return [...pick(".test.ts"), ...pick(".test.tsx")];
}
const failureBlockLimit = 60;
function envEnabled(name) {
@@ -193,7 +201,7 @@ function invokedDirectly() {
async function runTests() {
const extra = process.argv.slice(2);
if (!gateMode()) {
const code = await runRunner(["--test", ...testGlobs, ...extra]);
const code = await runRunner(["--test", ...testFiles(), ...extra]);
process.exit(code);
}
@@ -208,7 +216,7 @@ async function runTests() {
"--test-reporter=tap",
"--test-reporter-destination",
tapPath,
...testGlobs,
...testFiles(),
...extra,
],
{ suppressFailedTestsTrailer: true },