Skip to content
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

Update --forceExit and "did not exit for one second" message colors. #8329

Merged
@@ -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

@@ -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`] = `
@@ -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`] = `
@@ -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.
@@ -120,22 +120,20 @@ const readResultsAndExit = (
if (globalConfig.forceExit) {
if (!globalConfig.detectOpenHandles) {
console.error(
This conversation was marked as resolved by scotthovestadt

This comment has been minimized.

Copy link
@thymikee

thymikee Apr 13, 2019

Collaborator

console.warn then (it still prints to stderr)?

This comment has been minimized.

Copy link
@scotthovestadt

scotthovestadt Apr 13, 2019

Author Contributor

Looks like it does print to stderr, docs say it's literally just an alias for console.error. I'll switch it.

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?',
);
}

exit(code);
} else if (!globalConfig.detectOpenHandles) {
setTimeout(() => {
console.error(
This conversation was marked as resolved by scotthovestadt

This comment has been minimized.

Copy link
@thymikee

thymikee Apr 13, 2019

Collaborator

console.warn?

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.',
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.