Skip to content

Instantly share code, notes, and snippets.

@bvaughn
Created August 23, 2021 21:37
Show Gist options
  • Save bvaughn/d415afbff48ea6009726bc4d6045aa45 to your computer and use it in GitHub Desktop.
Save bvaughn/d415afbff48ea6009726bc4d6045aa45 to your computer and use it in GitHub Desktop.
Jest config to remove extra console location / formatting noise
import { CustomConsole } from '@jest/console';
function formatter(type, message) {
switch(type) {
case 'error':
return "\x1b[31m" + message + "\x1b[0m";
case 'warn':
return "\x1b[33m" + message + "\x1b[0m";
case 'log':
default:
return message;
}
}
global.console = new CustomConsole(
process.stdout,
process.stderr,
formatter,
);
@bvaughn
Copy link
Author

bvaughn commented Aug 23, 2021

See before:

Screen Shot 2021-08-23 at 3 11 21 PM

and after:

Screen Shot 2021-08-23 at 3 11 55 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment