Skip to content

Commit

Permalink
Update --forceExit and "did not exit for one second" message colors. (#…
Browse files Browse the repository at this point in the history
…8329)

* Update --forceExit message color.

* Update "Jest did not exit one second" message color.

* Update CHANGELOG.md

* console.error -> console.warn
  • Loading branch information
scotthovestadt committed Apr 14, 2019
1 parent c7bcefb commit ac8c345
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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))
- `[expect]` Improve report when matcher fails, part 16 ([#8306](https://github.com/facebook/jest/pull/8306))
- `[jest-runner]` Pass docblock pragmas to TestEnvironment constructor ([#8320](https://github.com/facebook/jest/pull/8320))

Expand Down
Expand Up @@ -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`] = `
Expand Down
Expand Up @@ -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`] = `
Expand Down
6 changes: 1 addition & 5 deletions 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.
Expand Down
16 changes: 7 additions & 9 deletions packages/jest-cli/src/cli/index.ts
Expand Up @@ -119,23 +119,21 @@ 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?',
),
console.warn(
chalk.bold('Force exiting Jest: ') +
'Have you considered using `--detectOpenHandles` to detect ' +
'async operations that kept running after all tests finished?',
);
}

exit(code);
} else if (!globalConfig.detectOpenHandles) {
setTimeout(() => {
console.error(
chalk.red.bold(
console.warn(
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.',
Expand Down

0 comments on commit ac8c345

Please sign in to comment.