fancive_obsidian-parallel-r.../scripts/run-tests.mjs
wujunchen 1fff3cb343 fix: address CR findings — test runner, CI dedup, error cause
- Create scripts/run-tests.mjs to auto-discover test files, replacing
  the 900-char inline test command in package.json (P3-1)
- Add test:only script for CI to avoid duplicate build+typecheck (P2-1)
- Preserve original SyntaxError as cause in responseJson (P2-3)

Change-Id: I51d0c8c51d3b0b648ed5ff4ea282bda070b0d457
2026-04-27 16:04:03 +08:00

24 lines
577 B
JavaScript

import { readdirSync } from 'fs';
import { execSync } from 'child_process';
import { join } from 'path';
const testsDir = join(import.meta.dirname, '..', 'tests');
const files = readdirSync(testsDir)
.filter((f) => f.endsWith('.test.js'))
.sort();
let failed = 0;
for (const file of files) {
const path = join(testsDir, file);
try {
execSync(`node ${path}`, { stdio: 'inherit' });
} catch {
failed++;
}
}
if (failed > 0) {
console.error(`\n${failed} test file(s) failed.`);
process.exit(1);
}
console.log(`\nAll ${files.length} test files passed.`);