From b9c3d3b1e0299885f8857cc30488874435b9d9f8 Mon Sep 17 00:00:00 2001 From: Scott Hovestadt Date: Sat, 13 Apr 2019 11:52:12 -0700 Subject: [PATCH 1/4] Update --forceExit message color. --- .../__snapshots__/cliHandlesExactFilenames.test.ts.snap | 4 +--- .../consoleLogOutputWhenRunInBand.test.ts.snap | 4 +--- e2e/__tests__/__snapshots__/detectOpenHandles.ts.snap | 6 +----- packages/jest-cli/src/cli/index.ts | 8 +++----- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/e2e/__tests__/__snapshots__/cliHandlesExactFilenames.test.ts.snap b/e2e/__tests__/__snapshots__/cliHandlesExactFilenames.test.ts.snap index e63fb4b64c14..1b384c13fd20 100644 --- a/e2e/__tests__/__snapshots__/cliHandlesExactFilenames.test.ts.snap +++ b/e2e/__tests__/__snapshots__/cliHandlesExactFilenames.test.ts.snap @@ -5,9 +5,7 @@ PASS foo/bar.spec.js ✓ foo -Force exiting Jest - -Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished? +Force exiting Jest: Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished? `; exports[`CLI accepts exact file names if matchers matched 2`] = ` diff --git a/e2e/__tests__/__snapshots__/consoleLogOutputWhenRunInBand.test.ts.snap b/e2e/__tests__/__snapshots__/consoleLogOutputWhenRunInBand.test.ts.snap index f8623ba1fdf0..c2c40961c895 100644 --- a/e2e/__tests__/__snapshots__/consoleLogOutputWhenRunInBand.test.ts.snap +++ b/e2e/__tests__/__snapshots__/consoleLogOutputWhenRunInBand.test.ts.snap @@ -5,9 +5,7 @@ PASS __tests__/a-banana.js ✓ banana -Force exiting Jest - -Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished? +Force exiting Jest: Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished? `; exports[`prints console.logs when run with forceExit 2`] = ` diff --git a/e2e/__tests__/__snapshots__/detectOpenHandles.ts.snap b/e2e/__tests__/__snapshots__/detectOpenHandles.ts.snap index bf7c5f83b396..eb668ee97c2f 100644 --- a/e2e/__tests__/__snapshots__/detectOpenHandles.ts.snap +++ b/e2e/__tests__/__snapshots__/detectOpenHandles.ts.snap @@ -1,10 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`prints message about flag on forceExit 1`] = ` -Force exiting Jest - -Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished? -`; +exports[`prints message about flag on forceExit 1`] = `Force exiting Jest: Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished?`; exports[`prints message about flag on slow tests 1`] = ` Jest did not exit one second after the test run has completed. diff --git a/packages/jest-cli/src/cli/index.ts b/packages/jest-cli/src/cli/index.ts index 2fef8672f9d2..362b11789330 100644 --- a/packages/jest-cli/src/cli/index.ts +++ b/packages/jest-cli/src/cli/index.ts @@ -120,11 +120,9 @@ const readResultsAndExit = ( if (globalConfig.forceExit) { if (!globalConfig.detectOpenHandles) { console.error( - chalk.red.bold('Force exiting Jest\n\n') + - chalk.red( - 'Have you considered using `--detectOpenHandles` to detect ' + - 'async operations that kept running after all tests finished?', - ), + chalk.bold('Force exiting Jest: ') + + 'Have you considered using `--detectOpenHandles` to detect ' + + 'async operations that kept running after all tests finished?', ); } From ce82bbccfa7d932ffd64fb4643b980aab9c998ee Mon Sep 17 00:00:00 2001 From: Scott Hovestadt Date: Sat, 13 Apr 2019 12:01:14 -0700 Subject: [PATCH 2/4] Update "Jest did not exit one second" message color. --- packages/jest-cli/src/cli/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest-cli/src/cli/index.ts b/packages/jest-cli/src/cli/index.ts index 362b11789330..a72ae342635a 100644 --- a/packages/jest-cli/src/cli/index.ts +++ b/packages/jest-cli/src/cli/index.ts @@ -130,10 +130,10 @@ const readResultsAndExit = ( } else if (!globalConfig.detectOpenHandles) { setTimeout(() => { console.error( - chalk.red.bold( + chalk.yellow.bold( 'Jest did not exit one second after the test run has completed.\n\n', ) + - chalk.red( + chalk.yellow( 'This usually means that there are asynchronous operations that ' + "weren't stopped in your tests. Consider running Jest with " + '`--detectOpenHandles` to troubleshoot this issue.', From 10dfbf1fe0fb2ff7c83081dd39486274a0fcc469 Mon Sep 17 00:00:00 2001 From: Scott Hovestadt Date: Sat, 13 Apr 2019 12:16:07 -0700 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e23216d3f0a3..61dbb28c8b2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features - `[expect]` Improve report when matcher fails, part 15 ([#8281](https://github.com/facebook/jest/pull/8281)) +- `[jest-cli]` Update `--forceExit` and "did not exit for one second" message colors ([#8329](https://github.com/facebook/jest/pull/8329)) ### Fixes From e9b9c475e56ad0868ad693ab2f0f1585004ea142 Mon Sep 17 00:00:00 2001 From: Scott Hovestadt Date: Sat, 13 Apr 2019 12:52:35 -0700 Subject: [PATCH 4/4] console.error -> console.warn --- packages/jest-cli/src/cli/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest-cli/src/cli/index.ts b/packages/jest-cli/src/cli/index.ts index a72ae342635a..800899896039 100644 --- a/packages/jest-cli/src/cli/index.ts +++ b/packages/jest-cli/src/cli/index.ts @@ -119,7 +119,7 @@ const readResultsAndExit = ( if (globalConfig.forceExit) { if (!globalConfig.detectOpenHandles) { - console.error( + console.warn( chalk.bold('Force exiting Jest: ') + 'Have you considered using `--detectOpenHandles` to detect ' + 'async operations that kept running after all tests finished?', @@ -129,7 +129,7 @@ const readResultsAndExit = ( exit(code); } else if (!globalConfig.detectOpenHandles) { setTimeout(() => { - console.error( + console.warn( chalk.yellow.bold( 'Jest did not exit one second after the test run has completed.\n\n', ) +