-
Notifications
You must be signed in to change notification settings - Fork 22
/
run-test.js
69 lines (61 loc) · 1.73 KB
/
run-test.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"use strict";
var jasmine = require('jasmine-node');
var path = require('path');
var Q = require("q");
//for(var key in jasmine) {
// global[key] = jasmine[key];
//}
var isVerbose = true;
var showColors = true;
var junitreport = {
report: false,
savePath: path.join(__dirname, "junitreport/"),
consolidate: true,
useDotNotation: false
};
process.argv.forEach(function(arg){
switch(arg) {
case '--color': showColors = true; break;
case '--noColor': showColors = false; break;
case '--verbose': isVerbose = true; break;
case '--junit': junitreport.report = true; break;
}
});
/**
* from https://github.com/kriskowal/q-io/blob/master/spec/lib/jasmine-promise.js
*/
jasmine.Block.prototype.execute = function (onComplete) {
var spec = this.spec;
try {
var result = this.func.call(spec, onComplete);
// It seems Jasmine likes to return the suite if you pass it anything.
// So make sure it's a promise first.
if (result && typeof result.then === "function") {
Q.timeout(result, 500).then(function () {
onComplete();
}, function (error) {
spec.fail(error);
onComplete();
});
} else if (this.func.length === 0) {
onComplete();
}
} catch (error) {
spec.fail(error);
onComplete();
}
};
jasmine.executeSpecsInFolder({
"specFolders": [__dirname+ "/test"],
"onComplete": function(runner/*, log*/){
if (runner.results().failedCount === 0) {
process.exit(0);
}
else {
process.exit(1);
}
},
"isVerbose": isVerbose,
"showColors": showColors,
"junitreport": junitreport
});