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.
  • Loading branch information
remy committed Jul 11, 2013
1 parent a266bae commit 3b49c38
Show file tree
Hide file tree
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
Expand Up @@ -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') {
Expand Down
2 changes: 2 additions & 0 deletions test/unit/reporter.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 https://localhost:8080/base/usr/a.js and ' +
Expand Down

0 comments on commit 3b49c38

Please sign in to comment.