Skip to content

Commit

Permalink
fix(reporter): keep users exact formatError result
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason authored and dignifiedquire committed Apr 5, 2017
1 parent db9682c commit 17c2c43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/config/01-configuration-file.md
Expand Up @@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion lib/reporter.js
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions test/unit/reporter.spec.js
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 17c2c43

Please sign in to comment.