diff --git a/lib/reporter.js b/lib/reporter.js index 5d27767eb..342162ceb 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -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') { diff --git a/test/unit/reporter.spec.coffee b/test/unit/reporter.spec.coffee index 1f5074ee5..fa416f24e 100644 --- a/test/unit/reporter.spec.coffee +++ b/test/unit/reporter.spec.coffee @@ -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 ' +