steptimeout.js
914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var failed = [];
var casper = require('casper').create({
onStepTimeout: function(self) {
failed.push(self.requestUrl);
}
});
var links = [
'http://google.com/',
'http://akei.com/',
'http://lemonde.fr/',
'http://liberation.fr/',
'http://cdiscount.fr/'
];
var timeout = ~~casper.cli.get(0);
casper.options.stepTimeout = timeout > 0 ? timeout : 1000;
casper.echo('Testing with timeout=' + casper.options.stepTimeout + 'ms.');
casper.start();
casper.each(links, function(self, link) {
self.test.comment('Adding ' + link + ' to test suite');
self.thenOpen(link, function(self) {
var testStatus = self.test.pass;
if (failed.indexOf(self.requestUrl) > -1) {
self.test.fail(self.requestUrl);
} else {
self.test.pass(self.requestUrl);
}
});
});
casper.run(function(self) {
self.test.renderResults(true);
});