forked from StefanKjartansson/drf-react-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphantom-runner.js
39 lines (33 loc) · 994 Bytes
/
phantom-runner.js
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
'use strict';
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str) {
return this.slice(0, str.length) == str;
};
}
var system = require('system'),
hasTestFailures = false,
page = require('webpage').create(),
errorRegEx = /^not ok/,
finishRegEx = "# NOTE: disabled specs are usually a result of xdescribe.";
if (system.args.length < 2 ) {
console.log('Usage: run-jasmine.js URL');
phantom.exit(1);
}
page.onConsoleMessage = function(msg) {
if (!(msg.startsWith("#") || msg.startsWith("ok ") || msg.startsWith("not ok"))) {
return;
}
console.log(msg);
if(msg.match(errorRegEx) !== null) {
hasTestFailures = true;
}
if(msg === finishRegEx) {
phantom.exit(hasTestFailures ? 1 : 0);
}
};
page.open(system.args[1], function(status) {
if (status !== "success") {
console.log("Couldn't load the page");
}
system.stdout.writeLine("");
});