☕️ Classic, reliable, trusted test framework for Node.js and the browser
Fix couple errors missing codes (#3666)
Valeri Karpov414bc1e18435
diff --git a/lib/cli/run.js b/lib/cli/run.jsindex e6c14f67..1d8a26d8 100644--- a/lib/cli/run.js+++ b/lib/cli/run.js@@ -9,8 +9,10 @@const Mocha = require('../mocha');const ansi = require('ansi-colors');-const errors = require('../errors');-const createInvalidArgumentValueError = errors.createInvalidArgumentValueError;+const {+ createInvalidArgumentValueError,+ createMissingArgumentError+} = require('../errors');const {list,@@ -258,13 +260,15 @@ exports.builder = yargs =>// yargs.implies() isn't flexible enough to handle thisif (argv.invert && !('fgrep' in argv || 'grep' in argv)) {- throw new Error(- '"--invert" requires one of "--fgrep <str>" or "--grep <regexp>"'+ throw createMissingArgumentError(+ '"--invert" requires one of "--fgrep <str>" or "--grep <regexp>"',+ '--fgrep|--grep',+ 'string|regexp');}if (argv.compilers) {- throw new Error(+ throw createInvalidArgumentValueError(`--compilers is DEPRECATED and no longer supported.See ${ansi.cyan('https://git.io/vdcSr')} for migration information.`);diff --git a/test/integration/options.spec.js b/test/integration/options.spec.jsindex 81eac578..68545285 100644--- a/test/integration/options.spec.js+++ b/test/integration/options.spec.js@@ -346,6 +346,26 @@ describe('options', function() {done();});});++ it('should throw an error when `--invert` used in isolation', function(done) {+ args = ['--invert'];+ runMocha(+ 'options/grep.fixture.js',+ args,+ function(err, res) {+ if (err) {+ done(err);+ return;+ }+ expect(res, 'to satisfy', {+ code: 1,+ output: /--invert.*--grep <regexp>/+ });+ done();+ },+ {stdio: 'pipe'}+ );+ });});});