run.js
1.07 KB
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
39
40
if (!phantom.casperLoaded) {
console.log('This script must be invoked using the casperjs executable');
phantom.exit(1);
}
var fs = require('fs');
var utils = require('utils');
var f = utils.format;
var casper = require('casper').create({
faultTolerant: false
});
// Options from cli
casper.options.verbose = casper.cli.get('direct') || false;
casper.options.logLevel = casper.cli.get('log-level') || "error";
// Overriding Casper.open to prefix all test urls
casper.setFilter('open.location', function(location) {
if (!/^http/.test(location)) {
return f('file://%s/%s', phantom.casperPath, location);
}
return location;
});
var tests = [];
if (casper.cli.args.length) {
tests = casper.cli.args.filter(function(path) {
return fs.isFile(path) || fs.isDirectory(path);
});
} else {
casper.echo('No test path passed, exiting.', 'RED_BAR', 80);
casper.exit(1);
}
casper.test.on('tests.complete', function() {
this.renderResults(true, undefined, casper.cli.get('xunit') || undefined);
});
casper.test.runSuites.apply(casper.test, tests);