@reporters/junit 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +2 -1
- package/index.js +8 -2
- package/package.json +1 -1
- package/tests/index.test.js +2 -1
- package/tests/{output.js → output.v18.js} +5 -3
- package/tests/output.v19.js +31 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.4](https://github.com/MoLow/reporters/compare/junit-v1.0.3...junit-v1.0.4) (2023-04-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* allow multiple roots ([590df94](https://github.com/MoLow/reporters/commit/590df948f8a4626fc29e8ce185e08d2226a307ba))
|
|
9
|
+
|
|
3
10
|
## [1.0.3](https://github.com/MoLow/reporters/compare/junit-v1.0.2...junit-v1.0.3) (2023-03-12)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
[](https://www.npmjs.com/package/@reporters/junit) 
|
|
1
|
+
[](https://www.npmjs.com/package/@reporters/junit)  [](https://codecov.io/gh/MoLow/reporters)
|
|
2
|
+
|
|
2
3
|
# Junit Reporter
|
|
3
4
|
A Junit reporter for `node:test`.
|
|
4
5
|
intendend for use with major CI tools like Jenkins, CircleCI, etc that consume Junit reports.
|
package/index.js
CHANGED
|
@@ -41,6 +41,7 @@ module.exports = async function* junitReporter(source) {
|
|
|
41
41
|
yield '<?xml version="1.0" encoding="utf-8"?>\n';
|
|
42
42
|
yield '<testsuites>\n';
|
|
43
43
|
let currentSuite = null;
|
|
44
|
+
const roots = [];
|
|
44
45
|
|
|
45
46
|
function startTest(event) {
|
|
46
47
|
const originalSuite = currentSuite;
|
|
@@ -51,6 +52,9 @@ module.exports = async function* junitReporter(source) {
|
|
|
51
52
|
children: [],
|
|
52
53
|
};
|
|
53
54
|
originalSuite?.children.push(currentSuite);
|
|
55
|
+
if (!currentSuite.parent) {
|
|
56
|
+
roots.push(currentSuite);
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
for await (const event of source) {
|
|
@@ -69,7 +73,7 @@ module.exports = async function* junitReporter(source) {
|
|
|
69
73
|
startTest(event);
|
|
70
74
|
}
|
|
71
75
|
const currentTest = currentSuite;
|
|
72
|
-
if (currentSuite?.nesting === event.data.nesting
|
|
76
|
+
if (currentSuite?.nesting === event.data.nesting) {
|
|
73
77
|
currentSuite = currentSuite.parent;
|
|
74
78
|
}
|
|
75
79
|
currentTest.props.time = (event.data.details.duration_ms / 1000).toFixed(6);
|
|
@@ -113,6 +117,8 @@ module.exports = async function* junitReporter(source) {
|
|
|
113
117
|
break;
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
|
-
|
|
120
|
+
for (const suite of roots) {
|
|
121
|
+
yield treeToXML(suite);
|
|
122
|
+
}
|
|
117
123
|
yield '</testsuites>\n';
|
|
118
124
|
};
|
package/package.json
CHANGED
package/tests/index.test.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const { spawnSync } = require('child_process');
|
|
2
2
|
const assert = require('assert');
|
|
3
3
|
const { compareLines } = require('../../../tests/utils');
|
|
4
|
-
|
|
4
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
5
|
+
const output = require(`./output.${process.version.split('.')[0]}`);
|
|
5
6
|
|
|
6
7
|
const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example']);
|
|
7
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
stdout: `<\\?xml version="1.0" encoding="utf-8"\\?>
|
|
3
3
|
<testsuites>
|
|
4
|
-
\t<testsuite name="tests" time=".*" disabled="0" errors="0" tests="
|
|
4
|
+
\t<testsuite name="tests" time=".*" disabled="0" errors="0" tests="3" failures="1" skipped="0" hostname=".*">
|
|
5
5
|
\t\t<testcase name="is ok" time=".*" classname="test"/>
|
|
6
6
|
\t\t<testcase name="fails" time=".*" classname="test" failure="this is an error">
|
|
7
7
|
\t\t\t<failure type="testCodeFailure" message="this is an error">
|
|
@@ -15,12 +15,14 @@ module.exports = {
|
|
|
15
15
|
.*
|
|
16
16
|
.*
|
|
17
17
|
.*
|
|
18
|
-
.*
|
|
19
|
-
.*
|
|
20
18
|
code: 'ERR_TEST_FAILURE'
|
|
21
19
|
}
|
|
22
20
|
\t\t\t</failure>
|
|
23
21
|
\t\t</testcase>
|
|
22
|
+
\t\t<testcase name="is a diagnostic" time=".*" classname="test"/>
|
|
23
|
+
\t</testsuite>
|
|
24
|
+
\t<testsuite name="more tests" time=".*" disabled="0" errors="0" tests="1" failures="0" skipped="0" hostname=".*">
|
|
25
|
+
\t\t<testcase name="is ok" time=".*" classname="test"/>
|
|
24
26
|
\t</testsuite>
|
|
25
27
|
</testsuites>
|
|
26
28
|
`,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
stdout: `<\\?xml version="1.0" encoding="utf-8"\\?>
|
|
3
|
+
<testsuites>
|
|
4
|
+
\t<testsuite name="tests" time=".*" disabled="0" errors="0" tests="3" failures="1" skipped="0" hostname=".*">
|
|
5
|
+
\t\t<testcase name="is ok" time=".*" classname="test"/>
|
|
6
|
+
\t\t<testcase name="fails" time=".*" classname="test" failure="this is an error">
|
|
7
|
+
\t\t\t<failure type="testCodeFailure" message="this is an error">
|
|
8
|
+
\\[Error \\[ERR_TEST_FAILURE\\]: this is an error\\] {
|
|
9
|
+
failureType: 'testCodeFailure',
|
|
10
|
+
cause: Error: this is an error
|
|
11
|
+
.*
|
|
12
|
+
.*
|
|
13
|
+
.*
|
|
14
|
+
.*
|
|
15
|
+
.*
|
|
16
|
+
.*
|
|
17
|
+
.*
|
|
18
|
+
.*
|
|
19
|
+
.*
|
|
20
|
+
code: 'ERR_TEST_FAILURE'
|
|
21
|
+
}
|
|
22
|
+
\t\t\t</failure>
|
|
23
|
+
\t\t</testcase>
|
|
24
|
+
\t\t<testcase name="is a diagnostic" time=".*" classname="test"/>
|
|
25
|
+
\t</testsuite>
|
|
26
|
+
\t<testsuite name="more tests" time=".*" disabled="0" errors="0" tests="1" failures="0" skipped="0" hostname=".*">
|
|
27
|
+
\t\t<testcase name="is ok" time=".*" classname="test"/>
|
|
28
|
+
\t</testsuite>
|
|
29
|
+
</testsuites>
|
|
30
|
+
`,
|
|
31
|
+
};
|