Skip to content

Commit 2e3c380

Browse files
authored
junit: use data from all testsuites (#168)
Currently we only use testsuite[0]. Change this to accumulate values from all testsuites.
1 parent ed05a2e commit 2e3c380

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

dist/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16796,7 +16796,16 @@ const getSummary = (data) => {
1679616796
return '';
1679716797
}
1679816798

16799-
return parser.resultObject.testsuites.testsuite[0]['$'];
16799+
const summary = { errors: 0, failures: 0, skipped: 0, tests: 0, time: 0 };
16800+
for (const testsuite of parser.resultObject.testsuites.testsuite) {
16801+
const { errors, failures, skipped, tests, time } = testsuite['$'];
16802+
summary.errors += +errors;
16803+
summary.failures += +failures;
16804+
summary.skipped += +skipped;
16805+
summary.tests += +tests;
16806+
summary.time += +time;
16807+
}
16808+
return summary;
1680016809
};
1680116810

1680216811
const getTestCases = (data) => {
@@ -16812,7 +16821,7 @@ const getTestCases = (data) => {
1681216821
return '';
1681316822
}
1681416823

16815-
return parser.resultObject.testsuites.testsuite[0].testcase;
16824+
return parser.resultObject.testsuites.testsuite.map((t) => t.testcase).flat();
1681616825
};
1681716826

1681816827
const getNotSuccessTest = (options) => {
@@ -16853,7 +16862,7 @@ const getNotSuccessTest = (options) => {
1685316862
const toMarkdown = (summary, options) => {
1685416863
const { errors, failures, skipped, tests, time } = summary;
1685516864
const displayTime =
16856-
time > 60 ? `${(time / 60) | 0}m ${time % 60 | 0}s` : `${time}s`;
16865+
time > 60 ? `${(time / 60) | 0}m ${time % 60 | 0}s` : `${time.toFixed(3)}s`;
1685716866
const table = `| Tests | Skipped | Failures | Errors | Time |
1685816867
| ----- | ------- | -------- | -------- | ------------------ |
1685916868
| ${tests} | ${skipped} :zzz: | ${failures} :x: | ${errors} :fire: | ${displayTime} :stopwatch: |

src/junitXml.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,16 @@ const getSummary = (data) => {
4242
return '';
4343
}
4444

45-
return parser.resultObject.testsuites.testsuite[0]['$'];
45+
const summary = { errors: 0, failures: 0, skipped: 0, tests: 0, time: 0 };
46+
for (const testsuite of parser.resultObject.testsuites.testsuite) {
47+
const { errors, failures, skipped, tests, time } = testsuite['$'];
48+
summary.errors += +errors;
49+
summary.failures += +failures;
50+
summary.skipped += +skipped;
51+
summary.tests += +tests;
52+
summary.time += +time;
53+
}
54+
return summary;
4655
};
4756

4857
const getTestCases = (data) => {
@@ -58,7 +67,7 @@ const getTestCases = (data) => {
5867
return '';
5968
}
6069

61-
return parser.resultObject.testsuites.testsuite[0].testcase;
70+
return parser.resultObject.testsuites.testsuite.map((t) => t.testcase).flat();
6271
};
6372

6473
const getNotSuccessTest = (options) => {
@@ -99,7 +108,7 @@ const getNotSuccessTest = (options) => {
99108
const toMarkdown = (summary, options) => {
100109
const { errors, failures, skipped, tests, time } = summary;
101110
const displayTime =
102-
time > 60 ? `${(time / 60) | 0}m ${time % 60 | 0}s` : `${time}s`;
111+
time > 60 ? `${(time / 60) | 0}m ${time % 60 | 0}s` : `${time.toFixed(3)}s`;
103112
const table = `| Tests | Skipped | Failures | Errors | Time |
104113
| ----- | ------- | -------- | -------- | ------------------ |
105114
| ${tests} | ${skipped} :zzz: | ${failures} :x: | ${errors} :fire: | ${displayTime} :stopwatch: |

0 commit comments

Comments
 (0)