Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Simple command line javascript test runner using phantomjs-node

View phantomTestRunner.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
var phantom = require('phantom');
phantom.create(function(ph) {
return ph.createPage(function(page) {
return page.open("http://localhost:8090/runner.html", function(status) {
return page.evaluate((function() {
 
var results = $(document.body).find('.description')[0].text;
var failures = $(document.body).find(".description:contains('failures')");
if (failures.size() > 0) return "All tests passed! %@".fmt(results);
 
var suite = $(document.body).find('.suite.failed').find('.description')[0].text;
var name = $(document.body).find('.spec.failed').find('.description').text();
var error = $(document.body).find('.spec.failed').find('.resultMessage.fail').text();
var stack = $(document.body).find('.spec.failed').find('.stackTrace').text();
return "%@ '%@ %@' %@ %@".fmt(results, suite, name, error, stack);
 
}), function(result) {
console.log(result);
return ph.exit();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.