From db15b517eea610f617e00d6d36ca37b53780df62 Mon Sep 17 00:00:00 2001 From: juergba Date: Sat, 8 Feb 2020 17:36:30 +0100 Subject: [PATCH] throw when opts is used --- lib/cli/run.js | 7 +++++++ test/integration/options/opts.spec.js | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/integration/options/opts.spec.js diff --git a/lib/cli/run.js b/lib/cli/run.js index 94c7c991fb..cf56f3ac07 100644 --- a/lib/cli/run.js +++ b/lib/cli/run.js @@ -279,6 +279,13 @@ exports.builder = yargs => ); } + if (argv.opts) { + throw createUnsupportedError( + `--opts: configuring Mocha via 'mocha.opts' is DEPRECATED and no longer supported. + Please use a configuration file instead.` + ); + } + // load requires first, because it can impact "plugin" validation handleRequires(argv.require); validatePlugin(argv, 'reporter', Mocha.reporters); diff --git a/test/integration/options/opts.spec.js b/test/integration/options/opts.spec.js new file mode 100644 index 0000000000..30b129f316 --- /dev/null +++ b/test/integration/options/opts.spec.js @@ -0,0 +1,23 @@ +'use strict'; + +var invokeMocha = require('../helpers').invokeMocha; + +describe('--opts', function() { + it('should report deprecation', function(done) { + invokeMocha( + ['--opts', './test/mocha.opts'], + function(err, res) { + if (err) { + return done(err); + } + expect( + res, + 'to have failed with output', + /'mocha.opts' is DEPRECATED/i + ); + done(); + }, + 'pipe' + ); + }); +});