diff --git a/docs/config/01-configuration-file.md b/docs/config/01-configuration-file.md index 0b8af457e..a97730693 100644 --- a/docs/config/01-configuration-file.md +++ b/docs/config/01-configuration-file.md @@ -652,11 +652,11 @@ Note: Just about all additional reporters in Karma (other than progress) require **Arguments:** - * `msg` - The entire assertion error and stack trace as a string. + * `msg` - A single line of the assertion error and stack trace (called for each line). -**Returns:** A new error message string. +**Returns:** A new error message line. -**Description:** Format assertion errors and stack traces. Useful for removing vendors and compiled sources. +**Description:** Format assertion errors and stack traces. Useful for removing vendors and compiled sources. Return an empty line `''` to remove it. The CLI option should be a path to a file that exports the format function. This can be a function exported at the root of the module or an export named `formatError`. diff --git a/lib/reporter.js b/lib/reporter.js index 72754c426..75d7bb5a6 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -96,7 +96,7 @@ var createErrorFormatter = function (config, emitter, SourceMapConsumer) { // allow the user to format the error if (config.formatError) { - msg = config.formatError(msg) + return config.formatError(msg) } return msg + '\n' diff --git a/test/unit/reporter.spec.js b/test/unit/reporter.spec.js index ec8e05254..27d88ae69 100644 --- a/test/unit/reporter.spec.js +++ b/test/unit/reporter.spec.js @@ -48,11 +48,11 @@ describe('reporter', () => { expect(spy.firstCall.args[0]).to.equal(ERROR) }) - it('should display the error returned by config.formatError', () => { + it('should display the exact error returned by config.formatError', () => { var formattedError = 'A new error' formatError = m.createErrorFormatter({ basePath: '', formatError: () => formattedError }, emitter) - expect(formatError('Something', '\t')).to.equal(formattedError + '\n') + expect(formatError('Something', '\t')).to.equal(formattedError) }) it('should indent', () => {