mirror of https://github.com/vitalif/phantomjs
run-jasmine example: Ensure exit code is always returned.
https://github.com/ariya/phantomjs/pull/124862.0
parent
1e7829db97
commit
3be7005a17
|
@ -50,8 +50,8 @@ page.onConsoleMessage = function(msg) {
|
|||
|
||||
page.open(system.args[1], function(status){
|
||||
if (status !== "success") {
|
||||
console.log("Unable to access network");
|
||||
phantom.exit();
|
||||
console.log("Unable to open " + system.args[1]);
|
||||
phantom.exit(1);
|
||||
} else {
|
||||
waitFor(function(){
|
||||
return page.evaluate(function(){
|
||||
|
@ -59,25 +59,30 @@ page.open(system.args[1], function(status){
|
|||
});
|
||||
}, function(){
|
||||
var exitCode = page.evaluate(function(){
|
||||
console.log('');
|
||||
console.log(document.body.querySelector('.description').innerText);
|
||||
var list = document.body.querySelectorAll('.results > #details > .specDetail.failed');
|
||||
if (list && list.length > 0) {
|
||||
console.log('');
|
||||
console.log(list.length + ' test(s) FAILED:');
|
||||
for (i = 0; i < list.length; ++i) {
|
||||
var el = list[i],
|
||||
desc = el.querySelector('.description'),
|
||||
msg = el.querySelector('.resultMessage.fail');
|
||||
try {
|
||||
console.log('');
|
||||
console.log(document.body.querySelector('.description').innerText);
|
||||
var list = document.body.querySelectorAll('.results > #details > .specDetail.failed');
|
||||
if (list && list.length > 0) {
|
||||
console.log('');
|
||||
console.log(desc.innerText);
|
||||
console.log(msg.innerText);
|
||||
console.log('');
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
console.log(document.body.querySelector('.alert > .passingAlert.bar').innerText);
|
||||
return 0;
|
||||
console.log(list.length + ' test(s) FAILED:');
|
||||
for (i = 0; i < list.length; ++i) {
|
||||
var el = list[i],
|
||||
desc = el.querySelector('.description'),
|
||||
msg = el.querySelector('.resultMessage.fail');
|
||||
console.log('');
|
||||
console.log(desc.innerText);
|
||||
console.log(msg.innerText);
|
||||
console.log('');
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
console.log(document.body.querySelector('.alert > .passingAlert.bar').innerText);
|
||||
return 0;
|
||||
}
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
phantom.exit(exitCode);
|
||||
|
|
Loading…
Reference in New Issue