Skip to content

Commit

Permalink
fix(reporter): prevent throwing exception when null is sent to formatter
Browse files Browse the repository at this point in the history
In particular tests, the createErrorFormatter was recieving `null` instead of a string, causing the reporter to throw an exception and crash karma entirely. This was only happening in Firefox 22 - and I'm pretty sure it's due to the assert library I'm using, but better to protect against it.
remy committed Jul 11, 2013

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent a266bae commit 3b49c38
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reporter.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ var createErrorFormatter = function(basePath, urlRoot) {
return function(msg, indentation) {
// remove domain and timestamp from source files
// and resolve base path / absolute path urls into absolute path
msg = msg.replace(URL_REGEXP, function(full, prefix, path) {
msg = (msg || '').replace(URL_REGEXP, function(full, prefix, path) {
if (prefix === 'base') {
return basePath + path;
} else if (prefix === 'absolute') {
2 changes: 2 additions & 0 deletions test/unit/reporter.spec.coffee
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ describe 'reporter', ->
it 'should indent', ->
expect(formatError 'Something', '\t').to.equal '\tSomething\n'

it 'should handle empty message', ->
expect(formatError null).to.equal '\n'

it 'should remove domain from files', ->
expect(formatError 'file http://localhost:8080/base/usr/a.js and ' +

0 comments on commit 3b49c38

Please sign in to comment.