test.ts
| 1 | import { readdirSync } from 'fs'; |
| 2 | import { execFileSync } from 'child_process'; |
| 3 | import path from 'path'; |
| 4 | |
| 5 | const testsDir = path.resolve('tests'); |
| 6 | const files = readdirSync(testsDir) |
| 7 | .filter(f => f.endsWith('.test.ts')) |
| 8 | .sort(); |
| 9 | |
| 10 | let passed = 0; |
| 11 | let failed = 0; |
| 12 | |
| 13 | for (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 | |
| 25 | console.log(`\n${passed + failed} test files: ${passed} passed${failed ? `, ${failed} failed` : ''}`); |
| 26 | if (failed > 0) process.exit(1); |
| 27 |