-
Notifications
You must be signed in to change notification settings - Fork 176
/
Copy pathjson.js
executable file
·61 lines (41 loc) · 1.15 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
61
'use strict';
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.map((err) => {
return {
message: err.message,
stack: err.stack
};
});
}
if (notebook.coverage) {
report.coverage = notebook.coverage;
}
if (notebook.lint) {
report.lint = notebook.lint.lint;
}
this.report(JSON.stringify(report, null, 2));
};