Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Simple command line javascript test runner using phantomjs-node
var phantom = require('phantom');
phantom.create(function(ph) {
return ph.createPage(function(page) {
return"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('').text();
var stack = $(document.body).find('.spec.failed').find('.stackTrace').text();
return "%@ '%@ %@' %@ %@".fmt(results, suite, name, error, stack);
}), function(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.