Created
July 8, 2020 13:53
-
-
Save sidferreira/6af1edbb41aa9b3f638b2f912d3003f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function fixJestErrorStack(error: Error) { | |
if (error.stack) { | |
const lines: string[] = error.stack.split('\n'); | |
let indexToRemove = -1; | |
lines.forEach((line, index) => { | |
if (indexToRemove === -1 && line.match(new RegExp(/^\s+at /))) { | |
indexToRemove = index; | |
} | |
}); | |
if (indexToRemove >= 0) { | |
lines.splice(indexToRemove, 1); | |
} | |
error.stack = lines.join('\n'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment