fix(frontend-tests): expand test files in run-tests.mjs so Node 20 still runs the suite (BUG-1230)
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:
co-authored by
Claude Opus 5.5
parent
2c64b66423
commit
1252de3e63
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user