Files
youle_cocos/cocoscreator_projects/scripts/run-framework-tests.mjs
T
joywayerandClaude Opus 4.8 f693f45895 chore(framework): TS 测试基建(tsx+node:test) + core 常量
- 补 @types/node(tsconfig types:[node] 所需,原计划遗漏)
- tsconfig 加 allowImportingTsExtensions(import 带 .ts 后缀所需)
- test:framework 改用 run-framework-tests.mjs 递归枚举(node 20.13 <20.14 不支持 --test glob)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 14:20:25 +08:00

25 lines
923 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 递归收集 framework-tests 下所有 *.test.ts 交给 node 测试运行器。
// node --test 的 glob 模式需 v20.14+,本仓库当前 node 20.13.x 不支持,
// 故用此零依赖、跨平台 runner 显式枚举文件,保持 test:framework 行为一致。
import { readdirSync, statSync } from 'node:fs';
import { join } from 'node:path';
import { spawnSync } from 'node:child_process';
const root = 'framework-tests';
const files = [];
(function walk(dir) {
for (const entry of readdirSync(dir)) {
const p = join(dir, entry);
if (statSync(p).isDirectory()) walk(p);
else if (p.endsWith('.test.ts')) files.push(p);
}
})(root);
if (files.length === 0) {
console.error(`[run-framework-tests] 未发现任何 *.test.ts(root=${root})`);
process.exit(1);
}
const r = spawnSync(process.execPath, ['--import', 'tsx', '--test', ...files], { stdio: 'inherit' });
process.exit(r.status ?? 1);