diff --git a/src/adapter.js b/src/adapter.js index f499b0c..c02210f 100644 --- a/src/adapter.js +++ b/src/adapter.js @@ -3,8 +3,7 @@ var formatError = function(error) { var message = error.message; if (stack) { - var firstLine = stack.substring(0, stack.indexOf('\n')); - if (message && firstLine.indexOf(message) === -1) { + if (message && stack.indexOf(message) === -1) { stack = message + '\n' + stack; } diff --git a/test/adapter.spec.js b/test/adapter.spec.js index 5176ebc..cf1a2cc 100644 --- a/test/adapter.spec.js +++ b/test/adapter.spec.js @@ -342,4 +342,16 @@ describe('adapter mocha', function() { expect(createConfigObject(this.karma).globals).to.deep.eq(['__cov', 'test']); }); }); + + describe('formatError', function () { + + it('should properly format exceptions that contains \n in their message', function () { + var errLines = formatError(new Error('foo\nbar')).split('\n'); + expect(errLines[0]).to.contain('foo'); + expect(errLines[1]).to.equal('bar'); + expect(errLines[2]).to.not.contain('foo'); + expect(errLines[3]).to.not.contain('bar'); + }); + + }); });