Skip to content

Commit

Permalink
fix(console): Re-add Error: to the stack
Browse files Browse the repository at this point in the history
Chrome devtools looks for a pattern in stack traces and if it finds a match
it will shorten and linkify the stack, and apply sourcemaps. The pattern fails
when the "Error: " is removed. So we put it back for debugging's sake.
  • Loading branch information
johnjbarton committed Nov 10, 2018
1 parent fce80bf commit 2f1993c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/adapter.js
Expand Up @@ -70,6 +70,7 @@ function formatFailedStep (step) {
// Remove the message prior to processing the stack to prevent issues like
// https://github.com/karma-runner/karma-jasmine/issues/79
var stack = step.stack.replace('Error: ' + step.message, '')
var prefix = (stack === step.stack) ? '' : 'Error: '

var dirtyRelevantStack = getRelevantStackFrom(stack)

Expand All @@ -85,14 +86,14 @@ function formatFailedStep (step) {
} else {
// Stack entry is already in the message,
// we consider it to be a suitable message alternative:
relevantMessage.push(dirtyRelevantStack[i])
relevantMessage.push(prefix + dirtyRelevantStack[i])
}
}

// In most cases the above will leave us with an empty message...
if (relevantMessage.length === 0) {
// Let's reuse the original message:
relevantMessage.push(step.message)
relevantMessage.push(prefix + step.message)

// Now we probably have a repetition case where:
// relevantMessage: ["Expected true to be false."]
Expand Down

0 comments on commit 2f1993c

Please sign in to comment.