mocha icon indicating copy to clipboard operation
mocha copied to clipboard

🚀 Feature: Support setting options via environment vars

Open jedwards1211 opened this issue 4 years ago • 5 comments

As discussed in #4232, it can be difficult to pass mocha command-line options through npm run scripts. As @boneskull said:

yargs has a feature that supports setting options via an environment variable; we should probably take advantage of that at some point. Might even be an issue for it already.

I didn't see any open issues for this so figured I would open one.

jedwards1211 avatar Jun 10 '20 23:06 jedwards1211

sorry, butt-closed this one

yargs has support for this via .env() which we should be able to leverage.

boneskull avatar Jun 10 '20 23:06 boneskull

From reading the yargs docs seems like .env('MOCHA') should be sufficient, I'll open a PR soon

jedwards1211 avatar Jun 10 '20 23:06 jedwards1211

in my experience, it's never that easy, but I wish you luck regardless 😅

boneskull avatar Jun 10 '20 23:06 boneskull

You know, this just makes me wish yargs itself would accept an environment variable that's equivalent to .env('MOCHA') so I could do this kind of thing with any command built with yargs

jedwards1211 avatar Jun 10 '20 23:06 jedwards1211

https://github.com/mochajs/mocha/pull/4835

icholy avatar Dec 27 '23 16:12 icholy