From f742c33c072b490d01f24c59e9d41abb664339fa Mon Sep 17 00:00:00 2001 From: Jainam C Shah Date: Wed, 7 Oct 2020 17:59:07 +0530 Subject: [PATCH] Show suggestion only when unrecognized cli param length is greater than 1 --- CHANGELOG.md | 1 + packages/jest-validate/src/validateCLIOptions.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89e390c2d84d..9ab4fc676ba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/jest-validate/src/validateCLIOptions.ts b/packages/jest-validate/src/validateCLIOptions.ts index 72ad11aef1c9..875194ae798f 100644 --- a/packages/jest-validate/src/validateCLIOptions.ts +++ b/packages/jest-validate/src/validateCLIOptions.ts @@ -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}` : '');