Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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