test.ts
Raw
1import { readdirSync } from 'fs';
2import { execFileSync } from 'child_process';
3import path from 'path';
4
5const testsDir = path.resolve('tests');
6const files = readdirSync(testsDir)
7 .filter(f => f.endsWith('.test.ts'))
8 .sort();
9
10let passed = 0;
11let failed = 0;
12
13for (const file of files) {
14 const filePath = path.join(testsDir, file);
15 try {
16 execFileSync('bun', ['test', '--bail=1', '--timeout', '30000', filePath], {
17 stdio: 'inherit',
18 });
19 passed++;
20 } catch {
21 failed++;
22 }
23}
24
25console.log(`\n${passed + failed} test files: ${passed} passed${failed ? `, ${failed} failed` : ''}`);
26if (failed > 0) process.exit(1);
27