Created
October 31, 2011 13:36
-
-
Save joubertnel/1327495 to your computer and use it in GitHub Desktop.
PhantomJS script for test automation of SproutCore app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var allTestsURL = "http://localhost:4020/reader_core/en/current/tests.html"; | |
var failedItem; | |
var failureCount; | |
var failureMessage; | |
var failures; | |
var i, j; | |
var reportingDone = false; | |
var specDescription; | |
var specs; | |
if (phantom.state.length === 0) { | |
console.log('PhantomJS - setting up and starting tests.'); | |
phantom.viewportSize = { width:1024, height:768 }; | |
phantom.state = 'opening'; | |
phantom.open(allTestsURL); | |
} else { | |
window.setInterval(function() { | |
if (reportingDone === false) { | |
if (document.querySelector('div.runner.passed')) { | |
reportingDone = true; | |
phantom.exit(0); | |
} | |
if (document.querySelector('div.runner.failed')) { | |
failures = document.querySelectorAll('div.spec.failed'); | |
console.log('failure count=' + failures.length); | |
failureCount = failures.length; | |
for (i=0; i < failureCount; i++) { | |
console.log('Failure #' + i); | |
failedItem = failures[i]; | |
specDescription = failedItem.querySelector('a.description').attributes['title'].value; | |
console.log(specDescription); | |
failureMessage = failedItem.querySelector('div.messages').innerText; | |
console.log(' ' + failureMessage); | |
} | |
reportingDone = true; | |
phantom.exit(1); | |
} | |
} | |
}, 100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for pointing that out, ariya!