Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Fix yargs global pollution

Sylvester Keilf05a58f5616b
diff --git a/lib/cli/cli.js b/lib/cli/cli.js
index c17d68a9..2a075ca8 100755
--- a/lib/cli/cli.js
+++ b/lib/cli/cli.js
@@ -11,7 +11,7 @@
const debug = require('debug')('mocha:cli:cli');
const symbols = require('log-symbols');
-const yargs = require('yargs');
+const yargs = require('yargs/yargs');
const path = require('path');
const {loadOptions, YARGS_PARSER_CONFIG} = require('./options');
const commands = require('./commands');
@@ -32,7 +32,7 @@ exports.main = (argv = process.argv.slice(2)) => {
Error.stackTraceLimit = Infinity; // configurable via --stack-trace-limit?
- yargs
+ yargs(argv)
.scriptName('mocha')
.command(commands.run)
.command(commands.init)
diff --git a/test/node-unit/cli/run.spec.js b/test/node-unit/cli/run.spec.js
index 6dfe5aaa..ed93b091 100644
--- a/test/node-unit/cli/run.spec.js
+++ b/test/node-unit/cli/run.spec.js
@@ -7,7 +7,7 @@ describe('command', function() {
describe('run', function() {
describe('builder', function() {
const IGNORED_OPTIONS = new Set(['help', 'version']);
- const options = builder(require('yargs')).getOptions();
+ const options = builder(require('yargs/yargs')().reset()).getOptions();
['number', 'string', 'boolean', 'array'].forEach(type => {
describe(`${type} type`, function() {
Array.from(new Set(options[type])).forEach(option => {