Files
cdsl-cad/frontend/src/test.ts
T
2026-08-19 19:34:30 +08:00

23 lines
756 B
TypeScript

import { readdir } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
async function collectTests(root: string): Promise<string[]> {
const entries = await readdir(root, { withFileTypes: true });
const collected: string[] = [];
for (const entry of entries) {
const full = path.join(root, entry.name);
if (entry.isDirectory()) {
collected.push(...await collectTests(full));
} else if (entry.isFile() && entry.name.endsWith(".test.ts")) {
collected.push(full);
}
}
return collected;
}
const srcRoot = path.dirname(fileURLToPath(import.meta.url));
for (const testFile of (await collectTests(srcRoot)).sort()) {
await import(pathToFileURL(testFile).href);
}