diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json index edf15b0711ec..3323e7aeae7f 100644 --- a/packages/jest-runner/package.json +++ b/packages/jest-runner/package.json @@ -9,6 +9,7 @@ "license": "MIT", "main": "build/index.js", "dependencies": { + "chalk": "^2.4.2", "exit": "^0.1.2", "graceful-fs": "^4.1.15", "jest-config": "^24.0.0", diff --git a/packages/jest-runner/src/runTest.js b/packages/jest-runner/src/runTest.js index c9b15c1c643f..6f8f0d67f79c 100644 --- a/packages/jest-runner/src/runTest.js +++ b/packages/jest-runner/src/runTest.js @@ -30,6 +30,7 @@ import {getTestEnvironment} from 'jest-config'; import * as docblock from 'jest-docblock'; import {formatExecError} from 'jest-message-util'; import sourcemapSupport from 'source-map-support'; +import chalk from 'chalk'; type RunTestInternalResult = { leakDetector: ?LeakDetector, @@ -40,7 +41,11 @@ function freezeConsole(buffer: ConsoleBuffer, config: ProjectConfig) { // $FlowFixMe: overwrite it for pretty errors. `Object.freeze` works, but gives ugly errors buffer.push = function fakeConsolePush({message}) { const error = new ErrorWithStack( - `Cannot log after tests are done. Did you forget to wait for something async in your test?\nAttempted to log "${message}".`, + chalk.red( + `${chalk.bold( + 'Cannot log after tests are done.', + )} Did you forget to wait for something async in your test?`, + ) + `\nAttempted to log "${message}".`, fakeConsolePush, ); @@ -52,7 +57,7 @@ function freezeConsole(buffer: ConsoleBuffer, config: ProjectConfig) { true, ); - process.stderr.write(formattedError); + process.stderr.write('\n' + formattedError + '\n'); // TODO: set exit code in Jest 25 // process.exitCode = 1; };