Skip to content

Commit

Permalink
colors
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jan 27, 2019
1 parent f856f35 commit 16c2957
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/jest-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 7 additions & 2 deletions packages/jest-runner/src/runTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
);

Expand All @@ -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;
};
Expand Down

0 comments on commit 16c2957

Please sign in to comment.