From 90e0088a670bdfce9875eb3475a5590246ddc23b Mon Sep 17 00:00:00 2001 From: agc Date: Sat, 28 Jan 2023 19:06:52 +0100 Subject: [PATCH] ValentinH/jest-fail-on-console#30: Respect Jest --noStackTrace flag --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 40579ec..3e624aa 100644 --- a/index.js +++ b/index.js @@ -24,8 +24,9 @@ const init = ({ const stackLines = stack.split('\n') return ( `${chalk.red(message)}\n` + - `${stackLines - .map((line, index) => { + `${process.argv.indexOf("--noStackTrace") !== -1 + ? chalk.white(stackLines.slice(-1)) + : stackLines.map( (line, index) => { if (index === stackLines.length - 1) { return chalk.white(line) }