fix(前端测试): 修复 npm test 卡死——定时器泄漏 + 去套娃 + 强制退出/超时

- 根因:polling-backoff-recovery 测试断言失败后跳过 loop.dispose(),残留自续期定时器导致 node --test 子进程永不退出
- dead-code-cleanup:移除套娃用例 test_full_vitest_green(再跑一遍全量套件,放大问题),execSync 加 300s 超时;其余静态断言保留
- package.json:node --test --test-force-exit --test-timeout=180000
- CI workflow 前端测试步骤改为 npm test(与 package.json 单一来源)
- 修正 3 处过时期望值(轮询退避/品牌 files+taskType/巡店 delete_conditions)
- 验证:本地 666 用例全过,19-24s,无残留进程
This commit is contained in:
2026-09-13 10:51:19 +08:00
parent b7d4d325e0
commit c81ebb7053
7 changed files with 21 additions and 40 deletions
+10 -2
View File
@@ -30,13 +30,21 @@ test('测试在打包之前执行(失败即红,阻断产物上传)', () =>
assert.ok(testIdx !== -1 && packageIdx !== -1 && testIdx < packageIdx, 'mvn test 必须先于 package')
})
test('含前端测试 jobnode --test 契约测试)', () => {
test('含前端测试 jobnpm test 跑 node --test 契约测试)', () => {
const t = text()
assert.ok(/frontend-test/.test(t), t)
assert.ok(/node --test tests\/\*\.test\.ts/.test(t), t)
assert.ok(/run: npm test/.test(t), t)
assert.ok(/npm ci/.test(t), t)
})
test('前端测试脚本带防挂死参数(force-exit + timeout', () => {
const pkgPath = path.resolve(path.dirname(YML), '..', '..', 'frontend-vue', 'package.json')
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) as { scripts: Record<string, string> }
assert.ok(/node --test/.test(pkg.scripts.test), '测试脚本应基于 node --test')
assert.ok(/--test-force-exit/.test(pkg.scripts.test), '须带 --test-force-exit:避免残留句柄让套件永久挂起')
assert.ok(/--test-timeout=\d+/.test(pkg.scripts.test), '须带 --test-timeout:单个用例卡死时能失败退出')
})
test('前端含类型检查(vue-tsc', () => {
const t = text()
assert.ok(/npm run build/.test(t), '应执行 npm run build(vue-tsc + vite)')