Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix couple errors missing codes #3666

Merged
merged 2 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -258,13 +260,15 @@ exports.builder = yargs =>

// yargs.implies() isn't flexible enough to handle this
if (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.`
);
Expand Down
20 changes: 20 additions & 0 deletions test/integration/options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
);
});
});
});

Expand Down