-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if the maxWorkers has a value and raises an exception otherwise (…
…#4591) * Check if the maxWorkers has a value and raises an exception otherwise In this commit we are adding a new validation in the check method of the jest-cli package, so we raise an exception if the user tries to run Jest with undefined maxWorkers, e.g. jest --maxWorkers jest --maxWorkers 2 Some users were confusing -w as an alias to --watch, but in fact it is an alias to --maxWorkers. This change will also make this distinction clearer. Fixes issue #4577 * Add expected exception message in the check method tests * Improve error message for when maxWorkers is undefined
- Loading branch information
1 parent
7aa3017
commit 1cda2e2
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {Argv} from 'types/Argv'; | ||
import {check} from '../../cli/args'; | ||
|
||
describe('check', () => { | ||
it('returns true if the arguments are valid', () => { | ||
const argv: Argv = {}; | ||
expect(check(argv)).toBe(true); | ||
}); | ||
|
||
it('raises an exception if runInBand and maxWorkers are both specified', () => { | ||
const argv: Argv = {maxWorkers: 2, runInBand: true}; | ||
expect(() => check(argv)).toThrow( | ||
'Both --runInBand and --maxWorkers were specified', | ||
); | ||
}); | ||
|
||
it('raises an exception if onlyChanged and watchAll are both specified', () => { | ||
const argv: Argv = {onlyChanged: true, watchAll: true}; | ||
expect(() => check(argv)).toThrow( | ||
'Both --onlyChanged and --watchAll were specified', | ||
); | ||
}); | ||
|
||
it('raises an exception if findRelatedTests is specified with no file paths', () => { | ||
const argv: Argv = {_: [], findRelatedTests: true}; | ||
expect(() => check(argv)).toThrow( | ||
'The --findRelatedTests option requires file paths to be specified', | ||
); | ||
}); | ||
|
||
it('raises an exception if maxWorkers is specified with no number', () => { | ||
const argv: Argv = {maxWorkers: undefined}; | ||
expect(() => check(argv)).toThrow( | ||
'The --maxWorkers (-w) option requires a number to be specified', | ||
); | ||
}); | ||
|
||
it('raises an exception if config is not a valid JSON string', () => { | ||
const argv: Argv = {config: 'x:1'}; | ||
expect(() => check(argv)).toThrow( | ||
'The --config option requires a JSON string literal, or a file path with a .js or .json extension', | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters