forked from hapijs/lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson.js
executable file
·60 lines (38 loc) · 1.08 KB
/
json.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
'use strict';
// Load modules
// Declare internals
const internals = {};
exports = module.exports = internals.Reporter = function (options) {
this.settings = options;
};
internals.Reporter.prototype.start = function (notebook) {
};
internals.Reporter.prototype.test = function (test) {
};
internals.Reporter.prototype.end = function (notebook) {
const tests = {};
notebook.tests.forEach((test) => {
const path = test.path.join('/');
tests[path] = tests[path] || [];
tests[path].push({
title: test.relativeTitle,
err: (test.err ? test.err.message : false),
duration: test.duration
});
});
const report = {
tests,
duration: notebook.ms,
leaks: notebook.leaks
};
if (notebook.errors.length) {
report.errors = notebook.errors;
}
if (notebook.coverage) {
report.coverage = notebook.coverage;
}
if (notebook.lint && notebook.lint.lint) {
report.lint = notebook.lint.lint;
}
this.report(JSON.stringify(report, null, 2));
};