Mocha: Add `--expose-internals` to `bin/mocha`'s allowed Node flags

Created on 3 Oct 2017  路  10Comments  路  Source: mochajs/mocha

Allow tools such as why-is-node-running to be used with Mocha calling mocha --expose-internals instead of node --expose-internals node_modules/mocha/bin/_mocha. Helps with #3044

chore semver-minor

Most helpful comment

I built this useful snippet to run the mocha tests programmatically and uses why-is-node-running to figure out why the process keeps running.

All 10 comments

There's no precedent for passing flags through for userland modules, though I could be mistaken.

Allow tools such as why-is-node-running

This is the only tool that wants the flag

Also, why-is-node-running is unmaintained and relies on Node.js internals which don't necessarily exist (internals/linked-list?). I'm loathe to offer explicit support for it--and indeed, I can't get it to give me much useful information. Async hooks, async wrap, or just a debugger are likely more useful.

I'd like to hold up on requesting a PR until there's some agreement about how to proceed.

Ultimately, teaching developers how to use debuggers or async_hooks is not really the best use of our resources. We can point them in the general direction of how to solve this, but a good portion of them may be better off simply adding the --exit flag.

--expose-internals is actually a(n undocumented) Node flag that why-is-node-running just happens to need since it uses the Node components affected by said flag, so while the immediate cause for wanting Mocha to pass it on is making why-is-node-running easier to use, ultimately it would also be useful for anyone wanting to test a library that requires --expose-internals. Um... if there are any. Not exactly a strong use case there I suppose; just want to be clear that it is a Node thing and not just a why-is-node-running thing.

Can't disagree on the value, or rather lack thereof, of why-is-node-running; sounds like a great module, hasn't held up to even a few days of scrutiny... Let's see how async hooks works out before we go any further out of our way to make why-is-node-running easier.

Ah, my bad, I didn't know that was a real flag. 馃槢

anyway, agreed; I'm happy to sit on this for a bit to see how it goes. here are the docs I've added for reference

@boneskull thanks for taking the time to write those docs!

I built this useful snippet to run the mocha tests programmatically and uses why-is-node-running to figure out why the process keeps running.

outdated.
Mocha uses package node-environment-flags or process.allowedNodeEnvironmentFlags to determine Node flags.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Almad picture Almad  路  41Comments

quangv picture quangv  路  38Comments

haraldrudell picture haraldrudell  路  52Comments

moll picture moll  路  46Comments

keithamus picture keithamus  路  37Comments