(name, fn)
| 95 | let currentSandbox = null; |
| 96 | |
| 97 | function test(name, fn) { |
| 98 | const start = Date.now(); |
| 99 | let passed = false; |
| 100 | let detail = ''; |
| 101 | currentSandbox = sandbox(); |
| 102 | try { |
| 103 | const result = fn(currentSandbox); |
| 104 | passed = result === true || result === undefined; |
| 105 | if (typeof result === 'string') { passed = false; detail = result; } |
| 106 | } catch (e) { |
| 107 | detail = e.message; |
| 108 | } |
| 109 | cleanup(currentSandbox); |
| 110 | const ms = Date.now() - start; |
| 111 | results.push({ name, passed, detail, ms }); |
| 112 | const icon = passed ? 'PASS' : 'FAIL'; |
| 113 | const suffix = detail ? `\n ${detail}` : ''; |
| 114 | console.log(` ${icon} ${name} (${ms}ms)${suffix}`); |
| 115 | } |
| 116 | |
| 117 | // ── Tests ──────────────────────────────────────────────────────────────────── |
| 118 |
no test coverage detected