Skip to content

Commit

Permalink
Show suggestion only when unrecognized cli param length is greater th…
Browse files Browse the repository at this point in the history
…an 1
  • Loading branch information
jcs98 committed Oct 7, 2020
1 parent 5da90b5 commit f742c33
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -37,6 +37,7 @@
- `[jest-console]` Add `Console` constructor to `console` object ([#10502](https://github.com/facebook/jest/pull/10502))
- `[jest-globals]` Fix lifecycle hook function types ([#10480](https://github.com/facebook/jest/pull/10480))
- `[jest-runtime]` Remove usage of `vm.compileFunction` due to a performance issue ([#10586](https://github.com/facebook/jest/pull/10586))
- `[jest-validate]` Show suggestion only when unrecognized cli param length is greater than 1 ([#10604](https://github.com/facebook/jest/pull/10604))

### Chore & Maintenance

Expand Down
8 changes: 4 additions & 4 deletions packages/jest-validate/src/validateCLIOptions.ts
Expand Up @@ -31,10 +31,10 @@ const createCLIValidationError = (

if (unrecognizedOptions.length === 1) {
const unrecognized = unrecognizedOptions[0];
const didYouMeanMessage = createDidYouMeanMessage(
unrecognized,
Array.from(allowedOptions),
);
const didYouMeanMessage =
unrecognized.length > 1
? createDidYouMeanMessage(unrecognized, Array.from(allowedOptions))
: '';
message =
` Unrecognized option ${chalk.bold(format(unrecognized))}.` +
(didYouMeanMessage ? ` ${didYouMeanMessage}` : '');
Expand Down

0 comments on commit f742c33

Please sign in to comment.