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
@@ -68,3 +68,11 @@
|
||||
| 推送 / 部署 / Gitea 页面 | 没做 |
|
||||
|
||||
快速门跑的时候改写了 `references/oracle/artifacts/pending_packets/` 下 5 个模板文件。那不是本单的改动,收尾时还原,不提交。
|
||||
|
||||
## Claude 验收与补修(2026-10-04)
|
||||
|
||||
- 实测:快速门 18 行(改前约 14,000 行);`CI=true npm test` 346 行,24 条已知失败的名字和报错都列出,退出码 1;本机 Node 22 `npm test` 输出 TAP,失败名单与开工基线逐条相同;快速门子步骤失败(假命令 exit 3)时打出 ✗、末 200 行、`gate-logs/01-fake-fail.log` 和退出码;`test_run_quality_gate_output.py` 10 条通过;workflow 合同测试唯二的失败(live staging sync 两条)本来就在基线 24 条里。
|
||||
- workflow 拆成 7 步,原 7 条命令一条不少、参数不变,没有吞退出码。
|
||||
- **补修(违反红线 4)**:`run-tests.mjs` 把 `tests/*.test.ts` 原样交给 `node --test`。Node 22 会自己展开,Node 20 不会,报「Could not find tests/*.test.ts」,一条测试都不跑;本机默认的 Node 就是 v20.19.2。改为脚本自己读 `tests/` 目录,`*.test.ts` 排序后接 `*.test.tsx` 排序,与 shell 展开的顺序相同。
|
||||
- 补修后,Node 20 下 4,932 项、69 条失败,与旧写法 `tsx --test tests/*.test.ts tests/*.test.tsx` 在 Node 20 下的失败名单逐条相同(都是 Node 20 自身的旧问题)。
|
||||
- Node 22 下 4,932 项、24 条失败,名单与基线相同;`CI=true` 时 346 行。
|
||||
|
||||
@@ -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