diff --git a/lib/stackparser.js b/lib/stackparser.js index 6b56567..54db969 100644 --- a/lib/stackparser.js +++ b/lib/stackparser.js @@ -1,15 +1,14 @@ +const regAssertParser = /(.*?)\n+(.*?)\n+(( at.*?file:\/\/(.*?):(\d+):(\d+).*?\)).*)/s + const stackParser = (stack) => { - const endOfLine = stack.indexOf('\n') + const m = stack.match(regAssertParser) - const title = stack.slice(0, endOfLine) + const info = m + .slice(1) + .map(x => x.trim()) + const [title, diff, stacktrace, where, file, line, column] = info - const at = stack.indexOf(' at ') - const diff = stack.slice(endOfLine + 1, at - 1) - - const endOfLineAfterAt = stack.slice(at).indexOf('\n') - const where = stack.slice(at + 3, at + endOfLineAfterAt) - - return { title, diff, where } + return { title, diff, where, file, line, column, stacktrace } } export { stackParser } \ No newline at end of file diff --git a/reporter/errorreporter.js b/reporter/errorreporter.js index 18b37cf..c6741a8 100644 --- a/reporter/errorreporter.js +++ b/reporter/errorreporter.js @@ -29,8 +29,8 @@ const prettyError = (error) => { const stack = stackParser(error.stack) log(chalk.yellowBright(stack.title) + '\n') - if (stack.diff != '\n ') - log(chalk.white(stack.diff)) + if (stack.diff != '') + log(chalk.white(stack.diff) + '\n') if (stack.where != '') log(chalk.gray(stack.where) + '\n')