Skip to content

Commit

Permalink
Merge pull request karma-runner#86 from r-park/fix-issue-79
Browse files Browse the repository at this point in the history
fix(adapter): remove error message from stack prior to processing stack
  • Loading branch information
maksimr committed Apr 25, 2015
2 parents d717537 + 57c64e8 commit 6ed9f5e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ function formatFailedStep(step) {

var relevantMessage = [];
var relevantStack = [];
var dirtyRelevantStack = getRelevantStackFrom(step.stack);

// 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 dirtyRelevantStack = getRelevantStackFrom(stack);

// PhantomJS returns multiline error message for errors coming from specs
// (for example when calling a non-existing function). This error is present
Expand Down
12 changes: 12 additions & 0 deletions test/adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ describe('jasmine adapter', function(){
expect( formatFailedStep(step) ).toBe( 'MESSAGE' );
});


it('should properly format message containing new-line characters', function(){
// FF does not have the message in the stack trace

var step = {
passed : false,
message : 'Jasmine fail\nmessage',
stack : 'Error: Jasmine fail\nmessage\[email protected]:123'
};

expect( formatFailedStep(step) ).toMatch( 'Jasmine fail\nmessage\[email protected]:123' );
});
});


Expand Down

0 comments on commit 6ed9f5e

Please sign in to comment.