-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseEvents.js
48 lines (48 loc) · 1.17 KB
/
parseEvents.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
var events = [];
function parseTest(test) {
var eventType = test.state;
if (test.pending) {
eventType = 'pending';
} else if (eventType === 'failed') {
eventType = 'fail';
} else if (eventType === 'passed') {
eventType = 'pass';
}
events.push([eventType, {
"err": test.err !== undefined ? {
"message": test.err.message,
"stack": test.err.stack,
"actual": test.err.actual,
"expected": test.err.expected
} : undefined,
"title": test.title,
"type": test.type,
"state": test.state,
"timedOut": test.timedOut,
"duration": test.duration,
"_fullTitle": test.fullTitle(),
"_slow": test.slow(),
"_trace": test._trace
}]);
events.push(['test end', {}]);
}
function parseSuite(suite) {
events.push(['suite', {
"title": suite.title,
"root": suite.root
}]);
suite.tests.forEach(function (test) {
parseTest(test);
});
suite.suites.forEach(function (suite) {
parseSuite(suite);
});
events.push(['suite end', {}])
}
function parseMocha(mocha) {
events.push(['start', undefined]);
parseSuite(mocha.suite);
events.push(['end', undefined])
}
parseMocha(mocha);
return JSON.stringify(events);