Skip to content

Commit

Permalink
throw when opts is used
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Feb 9, 2020
1 parent dcc255b commit db15b51
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/cli/run.js
Expand Up @@ -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);
Expand Down
23 changes: 23 additions & 0 deletions 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'
);
});
});

0 comments on commit db15b51

Please sign in to comment.