Skip to content

Instantly share code, notes, and snippets.

@xenophy
Created May 3, 2011 04:47
Show Gist options
  • Save xenophy/952831 to your computer and use it in GitHub Desktop.
Save xenophy/952831 to your computer and use it in GitHub Desktop.
Jasmin Driver for hantomjs support Jasmine 1.0.2
if (phantom.state.length === 0) {
if (phantom.args.length !== 1) {
console.log('Usage: run-jasmine.js URL');
phantom.exit();
} else {
phantom.state = 'run-jasmine';
phantom.open(phantom.args[0]);
}
} else {
window.setInterval(function () {
var list, el, desc, i, j;
if (document.body.querySelector('.finished-at')) {
console.log(document.body.querySelector('.description').innerText);
list = document.body.querySelectorAll('div.jasmine_reporter > div.suite.failed');
for (i = 0; i < list.length; ++i) {
el = list[i];
console.log('');
console.log('');
var specName = el.querySelector('.description').innerText;
console.log('[' + specName + ']');
spec = el.querySelectorAll('.spec');
for (j = 0; j < spec.length; ++j) {
var fail = spec[j].querySelector('div.resultMessage.fail');
var desc = spec[j].querySelector('.description');
if(fail) {
var line = '';
for(k=0; k<desc.innerText.length; k++) {
line += '-';
}
console.log(line);
console.log(desc.innerText);
console.log(line);
console.log(fail.innerText);
console.log('');
}
}
}
phantom.exit();
}
}, 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment