This repository has been archived by the owner on Jul 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtestRunner.js
71 lines (53 loc) · 1.9 KB
/
testRunner.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
70
71
//@TODO Catch errors on hooks
(function (window) {
"use strict";
var nof5 = window.nof5,
mocha = window.mocha;
jQuery(function onReady() {
nof5.connect(function onConnect(socket) {
var suites = [];
mocha.setup({
ui:"bdd",
globals: [
"io",
"getInterface", //getInterface seems to be a global function from mocha ^^
"stats",
"report"
]
});
mocha.Runner.prototype.on("suite", function (suite) {
if(suite.root) {
socket.emit("start", new Date());
}
if(suite.title !== "") {
suites.push(suite.title);
}
});
mocha.Runner.prototype.on("fail", function onFail(test) {
mocha.Runner.prototype.once("test end", function onTestEnd() {
var error = {
"suite": suites,
"test": test.title,
"type": test.err.toString()
};
socket.emit("fail", error);
});
});
mocha.Runner.prototype.on("suite end", function onSuiteEnd(suite) {
if (suite.root) {
suites = [];
socket.emit("end", new Date());
mocha.Runner.prototype.removeAllListeners("test end");
}
});
socket.on("disconnect", function onDisconnect() {
mocha.Runner.prototype.removeAllListeners();
});
socket.once("f5", function onf5() {
location.reload();
});
nof5.enableTests();
mocha.run();
});
});
})(window);