(name, fn)
| 20 | |
| 21 | // 测试辅助函数(支持同步和异步) |
| 22 | async function test(name, fn) { |
| 23 | testResults.total++; |
| 24 | try { |
| 25 | await fn(); |
| 26 | testResults.passed++; |
| 27 | console.log(`%c✓ ${name}`, "color: green;"); |
| 28 | return true; |
| 29 | } catch (error) { |
| 30 | testResults.failed++; |
| 31 | console.error(`%c✗ ${name}`, "color: red;", error); |
| 32 | return false; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | function testSync(name, fn) { |
| 37 | testResults.total++; |
no test coverage detected