lib/guard/jasmine/phantomjs/src/guard-jasmine.coffee in guard-jasmine-2.0.2 vs lib/guard/jasmine/phantomjs/src/guard-jasmine.coffee in guard-jasmine-2.0.3

- old
+ new

@@ -1,10 +1,11 @@ +system = require('system'); # Set default values options = - url: phantom.args[0] || 'http://localhost:3000/jasmine' - timeout: parseInt(phantom.args[1] || 10000) + url: system.args[0] || 'http://localhost:3000/jasmine' + timeout: parseInt(system.args.args[1] || 10000) # Create the web page. page = require('webpage').create() # Catch JavaScript errors @@ -13,11 +14,11 @@ reportError "Javascript error encountered on Jasmine test page: #{ message }", trace page.onResourceError = (error)-> page.reason = error.errorString page.reason_url = error.url - + # Once the page is initialized, setup the script for # the GuardReporter class page.onInitialized = -> page.injectJs 'guard-reporter.js' page.evaluate -> @@ -72,11 +73,15 @@ exitSuccessfully = -> results = page.evaluate -> window.reporter.results() console.log JSON.stringify( results ) phantomExit() +exitError = (message)-> + console.log JSON.stringify({error: message}) + phantomExit(1) + # Error message for when specs time out specsTimedout = -> text = page.evaluate -> document.getElementsByTagName('body')[0]?.innerText reportError """ Timeout waiting for the Jasmine test results! @@ -95,10 +100,13 @@ condition = false interval = undefined start = Date.now(0) wait = -> if !condition && (Date.now() - start < timeout) - condition = test() + try + condition = test() + catch e + exitError(e) else clearInterval interval if condition ready() else