diff --git a/lib/guard/jasmine/phantomjs/guard-jasmine.coffee b/lib/guard/jasmine/phantomjs/guard-jasmine.coffee index b5d7163..1c83fe9 100644 --- a/lib/guard/jasmine/phantomjs/guard-jasmine.coffee +++ b/lib/guard/jasmine/phantomjs/guard-jasmine.coffee @@ -24,7 +24,7 @@ errors = {} # Catch JavaScript errors # page.onError = (msg, trace) -> - if currentSpecId && currentSpecId isnt -1 + if currentSpecId errors[currentSpecId] ||= [] errors[currentSpecId].push({ msg: msg, trace: trace }) @@ -42,7 +42,7 @@ page.onConsoleMessage = (msg, line, source) -> logs[currentSpecId] = [] else - logs[currentSpecId].push(msg) if currentSpecId isnt -1 + logs[currentSpecId].push(msg) # Initialize the page before the JavaScript is run. # diff --git a/lib/guard/jasmine/phantomjs/guard-jasmine.js b/lib/guard/jasmine/phantomjs/guard-jasmine.js index 111bcdc..eefe6d8 100644 --- a/lib/guard/jasmine/phantomjs/guard-jasmine.js +++ b/lib/guard/jasmine/phantomjs/guard-jasmine.js @@ -1,3 +1,4 @@ +// Generated by CoffeeScript 1.3.3 (function() { var currentSpecId, errors, logs, options, page, specsReady, waitFor; @@ -21,7 +22,7 @@ errors = {}; page.onError = function(msg, trace) { - if (currentSpecId && currentSpecId !== -1) { + if (currentSpecId) { errors[currentSpecId] || (errors[currentSpecId] = []); return errors[currentSpecId].push({ msg: msg, @@ -44,9 +45,7 @@ currentSpecId = Number(RegExp.$1); return logs[currentSpecId] = []; } else { - if (currentSpecId !== -1) { - return logs[currentSpecId].push(msg); - } + return logs[currentSpecId].push(msg); } }; diff --git a/lib/guard/jasmine/phantomjs/lib/result.js b/lib/guard/jasmine/phantomjs/lib/result.js index 0da1018..4648859 100644 --- a/lib/guard/jasmine/phantomjs/lib/result.js +++ b/lib/guard/jasmine/phantomjs/lib/result.js @@ -1,3 +1,4 @@ +// Generated by CoffeeScript 1.3.3 (function() { var Result; @@ -76,6 +77,24 @@ return suite; }; + Result.prototype.addGlobalErrors = function(suite) { + var b, err, errMsg, globalErrors, noSpecs, noSuites, _i, _len, _ref; + noSuites = !suite.suites || suite.suites.length === 0; + noSpecs = !suite.specs || suite.specs.length === 0; + globalErrors = this.errors[-1] && this.errors[-1].length !== 0; + if (noSuites && noSpecs && globalErrors) { + err = this.errors[-1][0]; + errMsg = [err.msg]; + _ref = err.trace; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + b = _ref[_i]; + errMsg.push("\n " + b.file + ":" + b.line + " " + b["function"]); + } + suite.error = errMsg.join(""); + return suite.passed = false; + } + }; + Result.prototype.cleanResult = function(suite) { var s, spec, _i, _len, _ref; suite.suites = (function() { @@ -106,6 +125,7 @@ } if (this.options.errors !== 'never') { this.addErrors(this.result); + this.addGlobalErrors(this.result); } this.cleanResult(this.result); return this.result; diff --git a/lib/guard/jasmine/phantomjs/src/result.coffee b/lib/guard/jasmine/phantomjs/src/result.coffee index b10ccb6..83d7845 100644 --- a/lib/guard/jasmine/phantomjs/src/result.coffee +++ b/lib/guard/jasmine/phantomjs/src/result.coffee @@ -45,6 +45,19 @@ class Result suite + addGlobalError: (suite) -> + noSuites = !suite.suites || suite.suites.length == 0 + noSpecs = !suite.specs || suite.specs.length == 0 + globalErrors = @errors[-1] && @errors[-1].length != 0 + + if noSuites && noSpecs && globalErrors + err = @errors[-1][0] + errMsg = [ err.msg ] + for b in err.trace + errMsg.push "\n #{b.file}:#{b.line} #{b.function}" + suite.error = errMsg.join("") + suite.passed = false + # Clean unnecessary properties from the result # # @param [Object] suite the suite result @@ -69,7 +82,9 @@ class Result # process: -> @addLogs(@result) if @options.console isnt 'never' - @addErrors(@result) if @options.errors isnt 'never' + if @options.errors isnt 'never' + @addErrors(@result) + @addGlobalError(@result) @cleanResult(@result) @result