-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Check if the maxWorkers has a value and raises an exception otherwise #4591
Conversation
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
|
Codecov Report
@@ Coverage Diff @@
## master #4591 +/- ##
=======================================
Coverage 55.68% 55.68%
=======================================
Files 186 186
Lines 6348 6348
Branches 3 3
=======================================
Hits 3535 3535
Misses 2812 2812
Partials 1 1 Continue to review full report at Codecov.
|
|
||
it('raises an exception if config is not a valid JSON string', () => { | ||
const argv: Argv = {config: 'x:1'}; | ||
expect(() => check(argv)).toThrow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests, nice! I think we should at least check the core message of the error though.
Something like this would be more descriptive:
expect(() => check(argv)).toThrowError('not a valid JSON string');
packages/jest-cli/src/cli/args.js
Outdated
throw new Error( | ||
'The --maxWorkers option requires a number to be specified.\n' + | ||
'Example usage: jest --maxWorkers 2\n' + | ||
'Or did you mean --watch ?', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove the space before question mark.
Also, how about adjusting this to most common mistake:
- The --maxWorkers option
+ The --maxWorkers (-w) option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of inline comments, but generally looks good.
@cpojer Let's wait for CI to pass and it's basically ready to merge. |
Agree with @thymikee, this is a great PR. Thank you <3 |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
In this commit, we are adding a new validation in the
check
method of thejest-cli
package, so we raise an exception if the user tries to run Jest with undefinedmaxWorkers
Some users were confusing
-w
as an alias to--watch
, but in fact,-w
is an alias to--maxWorkers
. This change will also make this distinction clearer.Also, a new test file was added to the
jest-cli
package, in order to unit test thecheck
method.Fixes issue #4577
Test plan