Skip to content

Instantly share code, notes, and snippets.

@christian-schulze
Forked from bvaughn/setupFilesAfterEnv.js
Created August 24, 2021 09:57
Show Gist options
  • Save christian-schulze/fa73a28f6a43be4d4b9371e0f17e0e12 to your computer and use it in GitHub Desktop.
Save christian-schulze/fa73a28f6a43be4d4b9371e0f17e0e12 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,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment