mocha icon indicating copy to clipboard operation
mocha copied to clipboard

🚀 Feature: Disable timeout when require('node:inspector').url() !== undefined

Open kapouer opened this issue 3 years ago • 6 comments

It would be nice to disable timeout when one launch a test within node debugger.

It would prevent test from timing out during debugging, which is frustrating.

A way could be

if (require('node:inspector').url() !== undefined) this.timeout(0);

kapouer avatar Jun 16 '22 15:06 kapouer

Agreed

nopeless avatar Oct 07 '22 00:10 nopeless

I noticed that mocha checks if --inspect flag is set: https://github.com/mochajs/mocha/commit/d4adfa6364dff21c37e8632c3bfc9288c9938f42 however, when run in vscode test explorer, that flag isn't set, even when debugging. Hence the more thorough check proposed above.

kapouer avatar Oct 31 '22 10:10 kapouer

afaik, vscode uses the NODE_OPTIONS env arg instead of the flag

so, mocha should check this

nopeless avatar Oct 31 '22 15:10 nopeless

Yes, OTOH require('node:inspector').url() !== undefined is independent of the way it got in debugger mode.

kapouer avatar Oct 31 '22 15:10 kapouer

This seems like a useful feature, to the point where other test runners would probably do the same. I don't recall hitting this bug in Jest or Vitest so I'm guessing they might do some handling about it (or I just don't remember very well - also plausible!). Let's get a comparison table to see how other popular test frameworks handle this. If they do, then it'd be good to know what the list of "I seem to be running in debugger mode" conditions they check for.

JoshuaKGoldberg avatar Feb 06 '24 22:02 JoshuaKGoldberg