Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(console): Re-add Error: to the stack #228

Merged
merged 1 commit into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/adapter.js
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 deletions test/adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('jasmine adapter', function () {

karma.result.and.callFake(function (result) {
expect(result.log).toEqual([
'Expected true to be false.\n' +
'Error: Expected true to be false.\n' +
' at /foo/bar/baz.spec.js:23:29\n' +
' at /foo/bar/baz.js:18:20'
])
Expand All @@ -229,7 +229,7 @@ describe('jasmine adapter', function () {

karma.result.and.callFake(function (result) {
expect(result.log).toEqual([
'Expected true to be false.\n' +
'Error: Expected true to be false.\n' +
' at stack (/foo/bar/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1441:17)\n' +
' at buildExpectationResult (/foo/bar/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1411:14)\n' +
' at Spec.Env.expectationResultFactory (/foo/bar/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:533:18)\n' +
Expand Down