Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report javascript errors that prevent specs from running. #123

Merged
merged 1 commit into from
Apr 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/guard/jasmine/phantomjs/guard-jasmine.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 })

Expand All @@ -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.
#
Expand Down
7 changes: 3 additions & 4 deletions lib/guard/jasmine/phantomjs/guard-jasmine.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions lib/guard/jasmine/phantomjs/lib/result.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion lib/guard/jasmine/phantomjs/src/result.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down