Skip to content

Commit d212e74

Browse files
committed
logs(test-sdk): add per-test BEGIN/END diagnostics and 15s watchdog to pinpoint hanging test
1 parent 52c485e commit d212e74

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test-sdk/main.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ process.env.NODE_NO_WARNINGS = 1;
1010

1111
process.env.KIT = process.env.KIT || path.resolve(os.homedir(), '.kit');
1212

13+
// Global per-test diagnostics: BEGIN/END + watchdog
14+
ava.beforeEach((t) => {
15+
t.context.__start = Date.now()
16+
t.log(`[test-diag] BEGIN ${t.title}`)
17+
t.context.__timer = setTimeout(() => {
18+
console.log(`[test-diag] WARN still running after 15s: ${t.title}`)
19+
}, 15000)
20+
})
21+
22+
ava.afterEach.always((t) => {
23+
try { clearTimeout(t.context.__timer) } catch {}
24+
const dur = Date.now() - (t.context.__start || Date.now())
25+
t.log(`[test-diag] END ${t.title} in ${dur}ms`)
26+
})
27+
1328
ava.serial('app-prompt.js', async (t) => {
1429
let script = 'mock-script-with-arg';
1530
let scriptPath = kenvPath('scripts', `${script}.js`);

0 commit comments

Comments
 (0)