diff --git a/lib/cli/run.js b/lib/cli/run.js index 35498f5c39..1d8a26d872 100644 --- a/lib/cli/run.js +++ b/lib/cli/run.js @@ -9,9 +9,10 @@ const Mocha = require('../mocha'); const ansi = require('ansi-colors'); -const errors = require('../errors'); -const createInvalidArgumentValueError = errors.createInvalidArgumentValueError; -const createMissingArgumentError = errors.createMissingArgumentError; +const { + createInvalidArgumentValueError, + createMissingArgumentError +} = require('../errors'); const { list, @@ -261,17 +262,15 @@ exports.builder = yargs => if (argv.invert && !('fgrep' in argv || 'grep' in argv)) { throw createMissingArgumentError( '"--invert" requires one of "--fgrep " or "--grep "', - '--invert', - argv.invert + '--fgrep|--grep', + 'string|regexp' ); } if (argv.compilers) { throw createInvalidArgumentValueError( `--compilers is DEPRECATED and no longer supported. - See ${ansi.cyan('https://git.io/vdcSr')} for migration information.`, - '--compilers', - argv.compilers + See ${ansi.cyan('https://git.io/vdcSr')} for migration information.` ); } diff --git a/test/integration/options.spec.js b/test/integration/options.spec.js index 3b39fc6c89..6854528566 100644 --- a/test/integration/options.spec.js +++ b/test/integration/options.spec.js @@ -347,7 +347,7 @@ describe('options', function() { }); }); - it('fails if no --grep', function(done) { + it('should throw an error when `--invert` used in isolation', function(done) { args = ['--invert']; runMocha( 'options/grep.fixture.js', @@ -359,7 +359,7 @@ describe('options', function() { } expect(res, 'to satisfy', { code: 1, - output: /fgrep/ + output: /--invert.*--grep / }); done(); },