Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fabiofabbrucci/5525499 to your computer and use it in GitHub Desktop.
Save fabiofabbrucci/5525499 to your computer and use it in GitHub Desktop.
Load multiple pages and tests no errors js on load
How to test with phantomjs if some files have some JS errors
var urls = [
"index.php"
, "index.php?page=chisiamo"
];
var semaforo = new Array(urls.length);
console.log("**********************************");
console.log("Analyzing " + urls.length + " urls");
console.log("**********************************");
doAnalysis = function (i) {
var base = 'http://arbo/New/';
var page = require('webpage').create();
page.onError = function (msg, trace) {
console.log(msg);
trace.forEach(function(item) {
console.log(' ', item.file, ':', item.line);
});
phantom.exit();
}
page.open(base + urls[index], function(){
console.info((i+1) + ") " + page.url + ": DONE");
page.release();
semaforo[i] = true;
var all_true = true;
for (var ind = 0; ind < semaforo.length; ind++) {
all_true = all_true && semaforo[ind];
}
if(all_true){
console.log("----------------------------------");
phantom.exit();
}
});
}
for (var index = 0; index < urls.length; index++) {
doAnalysis(index);
}
{
"name": "Arbo",
"version": "1.0.0",
"author": "Fabio Fabbrucci <fabio.fabbrucci@gmail.com>",
"contributors": [
{
"name": "Danilo Sanchi",
"email": "danilo.sanchi@gmail.com"
}
],
"dependencies" : {
"phantomjs": "*"
},
"engines": {
"node": ">= 0.6.0"
}
}
./node_modules/phantomjs/bin/phantomjs ./app/Tests/javascript/no.errors.js
**********************************
Analyzing 2 urls
**********************************
2) http://arbo/New/index.php?page=chisiamo: DONE
1) http://arbo/New/index.php: DONE
----------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment