Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(reporter): keep users exact formatError result #2627

Merged
merged 3 commits into from
Apr 5, 2017
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
6 changes: 3 additions & 3 deletions docs/config/01-configuration-file.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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