Skip to content

@toranb /phantomTestRunner.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple command line javascript test runner using phantomjs-node
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.