Can you debug Bun tests?

I tried running bun test --inspect. It prints the Bun Inspector header:

bun test v1.0.0 (822a00c4)

lexer.test.ts:
--------------------- Bun Inspector ---------------------
Listening:
  ws://localhost:6499/2rmn49ur73
Inspect in browser:
  https://debug.bun.sh/#localhost:6499/2rmn49ur73
--------------------- Bun Inspector ---------------------

Unfortunately, it runs my tests, skipping over the debugger statements. Is there a way to make it pause?

Here’s the hack I came up with (a better answer would be appreciated). Busy wait for 10 seconds (enough time to open the inspector link):

const startTime = new Date();
while (new Date().getTime() - startTime.getTime() < 10000) {}
debugger;

Leave a Comment