diff --git a/lib/guard/jasmine/phantomjs/guard-jasmine.coffee b/lib/guard/jasmine/phantomjs/guard-jasmine.coffee index 1c83fe9..203a4f7 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 + if currentSpecId > -1 errors[currentSpecId] ||= [] errors[currentSpecId].push({ msg: msg, trace: trace }) @@ -41,7 +41,7 @@ page.onConsoleMessage = (msg, line, source) -> currentSpecId = Number(RegExp.$1) logs[currentSpecId] = [] - else + else if currentSpecId > -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 eefe6d8..c66ec9a 100644 --- a/lib/guard/jasmine/phantomjs/guard-jasmine.js +++ b/lib/guard/jasmine/phantomjs/guard-jasmine.js @@ -22,7 +22,7 @@ errors = {}; page.onError = function(msg, trace) { - if (currentSpecId) { + if (currentSpecId > -1) { errors[currentSpecId] || (errors[currentSpecId] = []); return errors[currentSpecId].push({ msg: msg, @@ -44,7 +44,7 @@ } else if (/^SPEC_START: (\d+)$/.test(msg)) { currentSpecId = Number(RegExp.$1); return logs[currentSpecId] = []; - } else { + } else if (currentSpecId > -1) { return logs[currentSpecId].push(msg); } };