Last active
December 17, 2015 00:59
-
-
Save fabiofabbrucci/5525499 to your computer and use it in GitHub Desktop.
Load multiple pages and tests no errors js on load
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to test with phantomjs if some files have some JS errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./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