@testomatio/reporter 1.6.13 → 2.0.1-beta-esm

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.
Files changed (142) hide show
  1. package/lib/adapter/codecept.d.ts +2 -0
  2. package/lib/adapter/codecept.js +295 -335
  3. package/lib/adapter/cucumber/current.d.ts +14 -0
  4. package/lib/adapter/cucumber/current.js +195 -203
  5. package/lib/adapter/cucumber/legacy.d.ts +0 -0
  6. package/lib/adapter/cucumber/legacy.js +130 -155
  7. package/lib/adapter/cucumber.d.ts +2 -0
  8. package/lib/adapter/cucumber.js +5 -16
  9. package/lib/adapter/cypress-plugin/index.d.ts +2 -0
  10. package/lib/adapter/cypress-plugin/index.js +93 -105
  11. package/lib/adapter/jasmine.d.ts +11 -0
  12. package/lib/adapter/jasmine.js +54 -53
  13. package/lib/adapter/jest.d.ts +13 -0
  14. package/lib/adapter/jest.js +97 -99
  15. package/lib/adapter/mocha.d.ts +2 -0
  16. package/lib/adapter/mocha.js +112 -140
  17. package/lib/adapter/playwright.d.ts +14 -0
  18. package/lib/adapter/playwright.js +195 -231
  19. package/lib/adapter/vitest.d.ts +35 -0
  20. package/lib/adapter/vitest.js +150 -149
  21. package/lib/adapter/webdriver.d.ts +24 -0
  22. package/lib/adapter/webdriver.js +134 -119
  23. package/lib/bin/cli.d.ts +2 -0
  24. package/lib/bin/cli.js +164 -211
  25. package/lib/bin/reportXml.d.ts +2 -0
  26. package/lib/bin/reportXml.js +49 -52
  27. package/lib/bin/startTest.d.ts +2 -0
  28. package/lib/bin/startTest.js +82 -95
  29. package/lib/bin/uploadArtifacts.d.ts +2 -0
  30. package/lib/bin/uploadArtifacts.js +55 -61
  31. package/lib/client.d.ts +76 -0
  32. package/lib/client.js +411 -465
  33. package/lib/config.d.ts +1 -0
  34. package/lib/config.js +16 -21
  35. package/lib/constants.d.ts +25 -0
  36. package/lib/constants.js +50 -44
  37. package/lib/data-storage.d.ts +34 -0
  38. package/lib/data-storage.js +206 -188
  39. package/lib/junit-adapter/adapter.d.ts +9 -0
  40. package/lib/junit-adapter/adapter.js +17 -20
  41. package/lib/junit-adapter/csharp.d.ts +4 -0
  42. package/lib/junit-adapter/csharp.js +18 -14
  43. package/lib/junit-adapter/index.d.ts +3 -0
  44. package/lib/junit-adapter/index.js +27 -25
  45. package/lib/junit-adapter/java.d.ts +5 -0
  46. package/lib/junit-adapter/java.js +41 -53
  47. package/lib/junit-adapter/javascript.d.ts +4 -0
  48. package/lib/junit-adapter/javascript.js +30 -27
  49. package/lib/junit-adapter/python.d.ts +5 -0
  50. package/lib/junit-adapter/python.js +38 -37
  51. package/lib/junit-adapter/ruby.d.ts +4 -0
  52. package/lib/junit-adapter/ruby.js +11 -8
  53. package/lib/output.d.ts +11 -0
  54. package/lib/output.js +44 -52
  55. package/lib/package.json +3 -0
  56. package/lib/pipe/bitbucket.d.ts +23 -0
  57. package/lib/pipe/bitbucket.js +210 -229
  58. package/lib/pipe/csv.d.ts +47 -0
  59. package/lib/pipe/csv.js +113 -126
  60. package/lib/pipe/debug.d.ts +29 -0
  61. package/lib/pipe/debug.js +104 -99
  62. package/lib/pipe/github.d.ts +30 -0
  63. package/lib/pipe/github.js +186 -213
  64. package/lib/pipe/gitlab.d.ts +23 -0
  65. package/lib/pipe/gitlab.js +166 -207
  66. package/lib/pipe/html.d.ts +34 -0
  67. package/lib/pipe/html.js +260 -319
  68. package/lib/pipe/index.d.ts +1 -0
  69. package/lib/pipe/index.js +84 -66
  70. package/lib/pipe/testomatio.d.ts +70 -0
  71. package/lib/pipe/testomatio.js +413 -462
  72. package/lib/reporter-functions.d.ts +34 -0
  73. package/lib/reporter-functions.js +28 -26
  74. package/lib/reporter.d.ts +232 -0
  75. package/lib/reporter.js +34 -29
  76. package/lib/services/artifacts.d.ts +33 -0
  77. package/lib/services/artifacts.js +55 -51
  78. package/lib/services/index.d.ts +9 -0
  79. package/lib/services/index.js +14 -12
  80. package/lib/services/key-values.d.ts +27 -0
  81. package/lib/services/key-values.js +56 -53
  82. package/lib/services/logger.d.ts +64 -0
  83. package/lib/services/logger.js +227 -245
  84. package/lib/template/testomatio.hbs +651 -1366
  85. package/lib/uploader.d.ts +60 -0
  86. package/lib/uploader.js +291 -360
  87. package/lib/utils/pipe_utils.d.ts +41 -0
  88. package/lib/utils/pipe_utils.js +89 -85
  89. package/lib/utils/utils.d.ts +45 -0
  90. package/lib/utils/utils.js +347 -307
  91. package/lib/xmlReader.d.ts +92 -0
  92. package/lib/xmlReader.js +490 -529
  93. package/package.json +57 -15
  94. package/src/adapter/codecept.js +375 -0
  95. package/src/adapter/cucumber/current.js +228 -0
  96. package/src/adapter/cucumber/legacy.js +158 -0
  97. package/src/adapter/cucumber.js +4 -0
  98. package/src/adapter/cypress-plugin/index.js +112 -0
  99. package/src/adapter/jasmine.js +60 -0
  100. package/src/adapter/jest.js +107 -0
  101. package/src/adapter/mocha.cjs +2 -0
  102. package/src/adapter/mocha.js +157 -0
  103. package/src/adapter/playwright.js +250 -0
  104. package/src/adapter/vitest.js +183 -0
  105. package/src/adapter/webdriver.js +142 -0
  106. package/src/bin/cli.js +280 -0
  107. package/src/bin/reportXml.js +74 -0
  108. package/src/bin/startTest.js +123 -0
  109. package/src/bin/uploadArtifacts.js +90 -0
  110. package/src/client.js +504 -0
  111. package/src/config.js +30 -0
  112. package/src/constants.js +53 -0
  113. package/src/data-storage.js +204 -0
  114. package/src/junit-adapter/adapter.js +23 -0
  115. package/src/junit-adapter/csharp.js +16 -0
  116. package/src/junit-adapter/index.js +28 -0
  117. package/src/junit-adapter/java.js +58 -0
  118. package/src/junit-adapter/javascript.js +31 -0
  119. package/src/junit-adapter/python.js +42 -0
  120. package/src/junit-adapter/ruby.js +10 -0
  121. package/src/output.js +57 -0
  122. package/src/pipe/bitbucket.js +254 -0
  123. package/src/pipe/csv.js +140 -0
  124. package/src/pipe/debug.js +104 -0
  125. package/src/pipe/github.js +233 -0
  126. package/src/pipe/gitlab.js +229 -0
  127. package/src/pipe/html.js +374 -0
  128. package/src/pipe/index.js +71 -0
  129. package/src/pipe/testomatio.js +503 -0
  130. package/src/reporter-functions.js +55 -0
  131. package/src/reporter.cjs_decprecated +21 -0
  132. package/src/reporter.js +33 -0
  133. package/src/services/artifacts.js +59 -0
  134. package/src/services/index.js +13 -0
  135. package/src/services/key-values.js +59 -0
  136. package/src/services/logger.js +316 -0
  137. package/src/template/emptyData.svg +23 -0
  138. package/src/template/testomatio.hbs +706 -0
  139. package/src/uploader.js +371 -0
  140. package/src/utils/pipe_utils.js +119 -0
  141. package/src/utils/utils.js +383 -0
  142. package/src/xmlReader.js +562 -0
package/lib/xmlReader.js CHANGED
@@ -1,553 +1,514 @@
1
- const debug = require('debug')('@testomatio/reporter:xml');
2
- const path = require('path');
3
- const chalk = require('chalk');
4
- const fs = require('fs');
5
- const { randomUUID } = require('crypto');
6
- const { XMLParser } = require('fast-xml-parser');
7
- const { APP_PREFIX, STATUS } = require('./constants');
8
- const {
9
- fetchFilesFromStackTrace,
10
- fetchIdFromOutput,
11
- fetchSourceCode,
12
- fetchSourceCodeFromStackTrace,
13
- fetchIdFromCode,
14
- humanize,
15
- } = require('./utils/utils');
16
- const S3Uploader = require('./uploader');
17
- const pipesFactory = require('./pipe');
18
- const adapterFactory = require('./junit-adapter');
19
- const config = require('./config');
20
-
21
- const ridRunId = randomUUID();
22
-
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const debug_1 = __importDefault(require("debug"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const picocolors_1 = __importDefault(require("picocolors"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const fast_xml_parser_1 = require("fast-xml-parser");
11
+ const constants_js_1 = require("./constants.js");
12
+ const crypto_1 = require("crypto");
13
+ const url_1 = require("url");
14
+ const utils_js_1 = require("./utils/utils.js");
15
+ const index_js_1 = require("./pipe/index.js");
16
+ const index_js_2 = __importDefault(require("./junit-adapter/index.js"));
17
+ const config_js_1 = require("./config.js");
18
+ const uploader_js_1 = require("./uploader.js");
19
+ // @ts-ignore this line will be removed in compiled code, because __dirname is defined in commonjs
20
+ const debug = (0, debug_1.default)('@testomatio/reporter:xml');
21
+ const ridRunId = (0, crypto_1.randomUUID)();
23
22
  const TESTOMATIO_URL = process.env.TESTOMATIO_URL || 'https://app.testomat.io';
24
- const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN, TESTOMATIO_MARK_DETACHED } =
25
- process.env;
26
-
23
+ const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN, TESTOMATIO_MARK_DETACHED } = process.env;
27
24
  const options = {
28
- ignoreDeclaration: true,
29
- ignoreAttributes: false,
30
- alwaysCreateTextNode: false,
31
- attributeNamePrefix: '',
32
- parseTagValue: true,
25
+ ignoreDeclaration: true,
26
+ ignoreAttributes: false,
27
+ alwaysCreateTextNode: false,
28
+ attributeNamePrefix: '',
29
+ parseTagValue: true,
33
30
  };
34
-
35
31
  const reduceOptions = {};
36
-
37
32
  class XmlReader {
38
- constructor(opts = {}) {
39
- this.requestParams = {
40
- apiKey: opts.apiKey || config.TESTOMATIO,
41
- url: opts.url || TESTOMATIO_URL,
42
- title: TESTOMATIO_TITLE,
43
- env: TESTOMATIO_ENV,
44
- group_title: TESTOMATIO_RUNGROUP_TITLE,
45
- detach: TESTOMATIO_MARK_DETACHED,
46
- // batch uploading is implemented for xml already
47
- isBatchEnabled: false,
48
- };
49
- this.runId = opts.runId || TESTOMATIO_RUN;
50
- this.adapter = adapterFactory(opts.lang?.toLowerCase(), opts);
51
- if (!this.adapter) throw new Error('XML adapter for this format not found');
52
-
53
- this.opts = opts || {};
54
- this.store = {};
55
- this.pipes = pipesFactory(opts, this.store);
56
-
57
- this.parser = new XMLParser(options);
58
- this.tests = [];
59
- this.stats = {};
60
- this.stats.language = opts.lang?.toLowerCase();
61
- this.uploader = new S3Uploader();
62
-
63
- this.version = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')).toString()).version;
64
- console.log(APP_PREFIX, `Testomatio Reporter v${this.version}`);
65
- }
66
-
67
- connectAdapter() {
68
- if (this.opts.javaTests) {
69
- this.adapter = adapterFactory('java', this.opts);
70
- return this.adapter;
33
+ constructor(opts = {}) {
34
+ this.requestParams = {
35
+ apiKey: opts.apiKey || config_js_1.config.TESTOMATIO,
36
+ url: opts.url || TESTOMATIO_URL,
37
+ title: TESTOMATIO_TITLE,
38
+ env: TESTOMATIO_ENV,
39
+ group_title: TESTOMATIO_RUNGROUP_TITLE,
40
+ detach: TESTOMATIO_MARK_DETACHED,
41
+ // batch uploading is implemented for xml already
42
+ isBatchEnabled: false,
43
+ };
44
+ this.runId = opts.runId || TESTOMATIO_RUN;
45
+ this.adapter = (0, index_js_2.default)(opts.lang?.toLowerCase(), opts);
46
+ if (!this.adapter)
47
+ throw new Error('XML adapter for this format not found');
48
+ this.opts = opts || {};
49
+ this.store = {};
50
+ this.pipesPromise = (0, index_js_1.pipesFactory)(opts, this.store);
51
+ this.parser = new fast_xml_parser_1.XMLParser(options);
52
+ this.tests = [];
53
+ this.stats = {};
54
+ this.stats.language = opts.lang?.toLowerCase();
55
+ this.uploader = new uploader_js_1.S3Uploader();
56
+ // @ts-ignore
57
+ const packageJsonPath = path_1.default.resolve(__dirname, '..', 'package.json');
58
+ this.version = JSON.parse(fs_1.default.readFileSync(packageJsonPath).toString()).version;
59
+ console.log(constants_js_1.APP_PREFIX, `Testomatio Reporter v${this.version}`);
71
60
  }
72
- this.adapter = adapterFactory(this.stats.language, this.opts);
73
- return this.adapter;
74
- }
75
-
76
- parse(fileName) {
77
- let xmlData = fs.readFileSync(path.resolve(fileName)).toString();
78
-
79
- // we remove too long stack traces
80
- const cutRegexes = [
81
- /(<output><!\[CDATA\[)([\s\S]*?)(\]\]><\/output>)/g,
82
- /(<system-err><!\[CDATA\[)([\s\S]*?)(\]\]><\/system-err>)/g,
83
- /(<system-out><!\[CDATA\[)([\s\S]*?)(\]\]><\/system-out>)/g,
84
- ];
85
-
86
- for (const regex of cutRegexes) {
87
- xmlData = xmlData.replace(regex, (_, p1, p2, p3) => `${p1}${p2.substring(0, 5000)}${p3}`);
61
+ connectAdapter() {
62
+ if (this.opts.javaTests) {
63
+ this.adapter = (0, index_js_2.default)('java', this.opts);
64
+ return this.adapter;
65
+ }
66
+ this.adapter = (0, index_js_2.default)(this.stats.language, this.opts);
67
+ return this.adapter;
88
68
  }
89
-
90
- const jsonResult = this.parser.parse(xmlData);
91
- let jsonSuite;
92
-
93
- if (jsonResult.testsuites) {
94
- jsonSuite = jsonResult.testsuites;
95
- } else if (jsonResult.testsuite) {
96
- jsonSuite = jsonResult;
97
- } else if (jsonResult.TestRun) {
98
- return this.processTRX(jsonResult);
99
- } else if (jsonResult['test-run']) {
100
- return this.processNUnit(jsonResult['test-run']);
101
- } else if (jsonResult.assemblies) {
102
- return this.processXUnit(jsonResult.assemblies);
103
- } else {
104
- console.log(jsonResult);
105
- throw new Error("Format can't be parsed");
69
+ parse(fileName) {
70
+ let xmlData = fs_1.default.readFileSync(path_1.default.resolve(fileName)).toString();
71
+ // we remove too long stack traces
72
+ const cutRegexes = [
73
+ /(<output><!\[CDATA\[)([\s\S]*?)(\]\]><\/output>)/g,
74
+ /(<system-err><!\[CDATA\[)([\s\S]*?)(\]\]><\/system-err>)/g,
75
+ /(<system-out><!\[CDATA\[)([\s\S]*?)(\]\]><\/system-out>)/g,
76
+ ];
77
+ for (const regex of cutRegexes) {
78
+ xmlData = xmlData.replace(regex, (_, p1, p2, p3) => `${p1}${p2.substring(0, 5000)}${p3}`);
79
+ }
80
+ const jsonResult = this.parser.parse(xmlData);
81
+ let jsonSuite;
82
+ if (jsonResult.testsuites) {
83
+ jsonSuite = jsonResult.testsuites;
84
+ }
85
+ else if (jsonResult.testsuite) {
86
+ jsonSuite = jsonResult;
87
+ }
88
+ else if (jsonResult.TestRun) {
89
+ return this.processTRX(jsonResult);
90
+ }
91
+ else if (jsonResult['test-run']) {
92
+ return this.processNUnit(jsonResult['test-run']);
93
+ }
94
+ else if (jsonResult.assemblies) {
95
+ return this.processXUnit(jsonResult.assemblies);
96
+ }
97
+ else {
98
+ console.log(jsonResult);
99
+ throw new Error("Format can't be parsed");
100
+ }
101
+ return this.processJUnit(jsonSuite);
106
102
  }
107
-
108
- return this.processJUnit(jsonSuite);
109
- }
110
-
111
- processJUnit(jsonSuite) {
112
- const { testsuite, name, tests, failures, errors } = jsonSuite;
113
-
114
- reduceOptions.preferClassname = this.stats.language === 'python';
115
- const resultTests = processTestSuite(testsuite);
116
-
117
- const hasFailures = resultTests.filter(t => t.status === 'failed').length > 0;
118
- const status = failures > 0 || errors > 0 || hasFailures ? 'failed' : 'passed';
119
-
120
- const time = testsuite.time || 0;
121
- // debug('time', jsonSuite, time)
122
- if (time) {
123
- if (!this.stats.duration) this.stats.duration = 0;
124
- this.stats.duration += parseFloat(time);
103
+ processJUnit(jsonSuite) {
104
+ const { testsuite, name, tests, failures, errors } = jsonSuite;
105
+ reduceOptions.preferClassname = this.stats.language === 'python';
106
+ const resultTests = processTestSuite(testsuite);
107
+ const hasFailures = resultTests.filter(t => t.status === 'failed').length > 0;
108
+ const status = failures > 0 || errors > 0 || hasFailures ? 'failed' : 'passed';
109
+ const time = testsuite.time || 0;
110
+ // debug('time', jsonSuite, time)
111
+ if (time) {
112
+ if (!this.stats.duration)
113
+ this.stats.duration = 0;
114
+ this.stats.duration += parseFloat(time);
115
+ }
116
+ this.tests = this.tests.concat(resultTests);
117
+ return {
118
+ create_tests: true,
119
+ duration: parseFloat(time),
120
+ failed_count: parseInt(failures, 10),
121
+ name,
122
+ passed_count: parseInt(tests, 10) - parseInt(failures, 10),
123
+ skipped_count: 0,
124
+ status,
125
+ tests: resultTests,
126
+ tests_count: parseInt(tests, 10),
127
+ };
125
128
  }
126
-
127
- this.tests = this.tests.concat(resultTests);
128
-
129
- return {
130
- status,
131
- create_tests: true,
132
- name,
133
- duration: parseFloat(time),
134
- tests_count: parseInt(tests, 10),
135
- passed_count: parseInt(tests, 10) - parseInt(failures, 10),
136
- failed_count: parseInt(failures, 10),
137
- skipped_count: 0,
138
- tests: resultTests,
139
- };
140
- }
141
-
142
- processNUnit(jsonSuite) {
143
- const { result, total, passed, failed, inconclusive, skipped } = jsonSuite;
144
-
145
- reduceOptions.preferClassname = this.stats.language === 'python';
146
- const resultTests = processTestSuite(jsonSuite['test-suite']);
147
-
148
- this.tests = this.tests.concat(resultTests);
149
-
150
- return {
151
- status: result?.toLowerCase(),
152
- create_tests: true,
153
- tests_count: parseInt(total, 10),
154
- passed_count: parseInt(passed, 10),
155
- failed_count: parseInt(failed, 10),
156
- skipped_count: parseInt(inconclusive + skipped, 10),
157
- tests: resultTests,
158
- };
159
- }
160
-
161
- processTRX(jsonSuite) {
162
- let defs = jsonSuite?.TestRun?.TestDefinitions?.UnitTest;
163
- if (!Array.isArray(defs)) defs = [defs].filter(d => !!d);
164
-
165
- const tests =
166
- defs.map(td => {
167
- const title = td.name.replace(/\(.*?\)/, '').trim();
168
- let example = td.name.match(/\((.*?)\)/);
169
- if (example) example = { ...example[1].split(',') };
170
- const suite = td.TestMethod.className.split(', ')[0].split('.');
171
- const suite_title = suite.pop();
129
+ processNUnit(jsonSuite) {
130
+ const { result, total, passed, failed, inconclusive, skipped } = jsonSuite;
131
+ reduceOptions.preferClassname = this.stats.language === 'python';
132
+ const resultTests = processTestSuite(jsonSuite['test-suite']);
133
+ this.tests = this.tests.concat(resultTests);
172
134
  return {
173
- title,
174
- example,
175
- file: suite.join('/'),
176
- description: td.Description,
177
- suite_title,
178
- id: td.Execution.id,
135
+ status: result?.toLowerCase(),
136
+ create_tests: true,
137
+ tests_count: parseInt(total, 10),
138
+ passed_count: parseInt(passed, 10),
139
+ failed_count: parseInt(failed, 10),
140
+ skipped_count: parseInt(inconclusive + skipped, 10),
141
+ tests: resultTests,
179
142
  };
180
- }) || [];
181
-
182
- let result = jsonSuite?.TestRun?.Results?.UnitTestResult;
183
- if (!Array.isArray(result)) result = [result].filter(d => !!d);
184
-
185
- const results = result.map(td => ({
186
- id: td.executionId,
187
- // seconds are used in junit reports, but ms are used by testomatio
188
- run_time: parseFloat(td.duration) * 1000,
189
- status: td.outcome,
190
- stack: td.Output.StdOut,
191
- files: td?.ResultFiles?.ResultFile?.map(rf => rf.path),
192
- }));
193
-
194
- results.forEach(r => {
195
- const test = tests.find(t => t.id === r.id) || {};
196
- r.suite_title = test.suite_title;
197
- r.title = test.title?.trim();
198
- if (test.code) r.code = test.code;
199
- if (test.description) r.description = test.description;
200
- if (test.example) r.example = test.example;
201
- if (test.file) r.file = test.file;
202
- r.create = true;
203
- if (r.status === 'Passed') r.status = STATUS.PASSED;
204
- if (r.status === 'Failed') r.status = STATUS.FAILED;
205
- if (r.status === 'Skipped') r.status = STATUS.SKIPPED;
206
- delete r.id;
207
- });
208
-
209
- debug(results);
210
-
211
- const counters = jsonSuite?.TestRun?.ResultSummary?.Counters || {};
212
-
213
- const failed_count = parseInt(counters.failed, 10) + parseInt(counters.error, 10);
214
-
215
- let status = STATUS.PASSED.toString();
216
- if (failed_count > 0) status = STATUS.FAILED;
217
-
218
- this.tests = results.filter(t => !!t.title);
219
-
220
- return {
221
- status,
222
- create_tests: true,
223
- tests_count: parseInt(counters.total, 10),
224
- passed_count: parseInt(counters.passed, 10),
225
- skipped_count: parseInt(counters.notExecuted, 10),
226
- failed_count,
227
- tests: results,
228
- };
229
- }
230
-
231
- processXUnit(assemblies) {
232
- const tests = [];
233
-
234
- assemblies = Array.isArray(assemblies.assembly) ? assemblies.assembly : [assemblies.assembly];
235
-
236
- assemblies.forEach(assembly => {
237
- const { collection } = assembly;
238
-
239
- const suites = Array.isArray(collection) ? collection : [collection];
240
-
241
- suites.forEach(suite => {
242
- const { test } = suite;
243
- if (!test) return;
244
- const cases = Array.isArray(test) ? test : [test];
245
- cases.forEach(testCase => {
246
- const { type, time, result } = testCase;
247
-
248
- let message = '';
249
- let stack = '';
250
-
251
- if (testCase.failure) {
252
- message = testCase.failure.message;
253
- stack = testCase.failure['stack-trace'];
254
- }
255
- if (testCase.reason) {
256
- message = testCase.reason.message;
257
- }
258
-
259
- let status = STATUS.PASSED;
260
- if (result === 'Pass') status = STATUS.PASSED;
261
- if (result === 'Fail') status = STATUS.FAILED;
262
- if (result === 'Skip') status = STATUS.SKIPPED;
263
-
264
- const pathParts = type.split('.');
265
- const suite_title = pathParts[pathParts.length - 1];
266
- const file = pathParts.slice(0, -1).join('/');
267
- const title = testCase.method || testCase.name.split('.').pop();
268
- const run_time = parseFloat(time) * 1000;
269
-
270
- tests.push({
271
- create: true,
272
- stack,
273
- message,
274
- file,
143
+ }
144
+ processTRX(jsonSuite) {
145
+ let defs = jsonSuite?.TestRun?.TestDefinitions?.UnitTest;
146
+ if (!Array.isArray(defs))
147
+ defs = [defs].filter(d => !!d);
148
+ const tests = defs.map(td => {
149
+ const title = td.name.replace(/\(.*?\)/, '').trim();
150
+ let example = td.name.match(/\((.*?)\)/);
151
+ if (example)
152
+ example = { ...example[1].split(',') };
153
+ const suite = td.TestMethod.className.split(', ')[0].split('.');
154
+ const suite_title = suite.pop();
155
+ return {
156
+ title,
157
+ example,
158
+ file: suite.join('/'),
159
+ description: td.Description,
160
+ suite_title,
161
+ id: td.Execution.id,
162
+ };
163
+ }) || [];
164
+ let result = jsonSuite?.TestRun?.Results?.UnitTestResult;
165
+ if (!Array.isArray(result))
166
+ result = [result].filter(d => !!d);
167
+ const results = result.map(td => ({
168
+ id: td.executionId,
169
+ // seconds are used in junit reports, but ms are used by testomatio
170
+ run_time: parseFloat(td.duration) * 1000,
171
+ status: td.outcome,
172
+ stack: td.Output.StdOut,
173
+ files: td?.ResultFiles?.ResultFile?.map(rf => rf.path),
174
+ }));
175
+ results.forEach(r => {
176
+ const test = tests.find(t => t.id === r.id) || {};
177
+ r.suite_title = test.suite_title;
178
+ r.title = test.title?.trim();
179
+ if (test.code)
180
+ r.code = test.code;
181
+ if (test.description)
182
+ r.description = test.description;
183
+ if (test.example)
184
+ r.example = test.example;
185
+ if (test.file)
186
+ r.file = test.file;
187
+ r.create = true;
188
+ if (r.status === 'Passed')
189
+ r.status = constants_js_1.STATUS.PASSED;
190
+ if (r.status === 'Failed')
191
+ r.status = constants_js_1.STATUS.FAILED;
192
+ if (r.status === 'Skipped')
193
+ r.status = constants_js_1.STATUS.SKIPPED;
194
+ delete r.id;
195
+ });
196
+ debug(results);
197
+ const counters = jsonSuite?.TestRun?.ResultSummary?.Counters || {};
198
+ const failed_count = parseInt(counters.failed, 10) + parseInt(counters.error, 10);
199
+ let status = constants_js_1.STATUS.PASSED.toString();
200
+ if (failed_count > 0)
201
+ status = constants_js_1.STATUS.FAILED;
202
+ this.tests = results.filter(t => !!t.title);
203
+ return {
275
204
  status,
276
- title,
277
- suite_title,
278
- run_time,
279
- });
205
+ create_tests: true,
206
+ tests_count: parseInt(counters.total, 10),
207
+ passed_count: parseInt(counters.passed, 10),
208
+ skipped_count: parseInt(counters.notExecuted, 10),
209
+ failed_count,
210
+ tests: results,
211
+ };
212
+ }
213
+ processXUnit(assemblies) {
214
+ const tests = [];
215
+ assemblies = Array.isArray(assemblies.assembly) ? assemblies.assembly : [assemblies.assembly];
216
+ assemblies.forEach(assembly => {
217
+ const { collection } = assembly;
218
+ const suites = Array.isArray(collection) ? collection : [collection];
219
+ suites.forEach(suite => {
220
+ const { test } = suite;
221
+ if (!test)
222
+ return;
223
+ const cases = Array.isArray(test) ? test : [test];
224
+ cases.forEach(testCase => {
225
+ const { type, time, result } = testCase;
226
+ let message = '';
227
+ let stack = '';
228
+ if (testCase.failure) {
229
+ message = testCase.failure.message;
230
+ stack = testCase.failure['stack-trace'];
231
+ }
232
+ if (testCase.reason) {
233
+ message = testCase.reason.message;
234
+ }
235
+ let status = constants_js_1.STATUS.PASSED;
236
+ if (result === 'Pass')
237
+ status = constants_js_1.STATUS.PASSED;
238
+ if (result === 'Fail')
239
+ status = constants_js_1.STATUS.FAILED;
240
+ if (result === 'Skip')
241
+ status = constants_js_1.STATUS.SKIPPED;
242
+ const pathParts = type.split('.');
243
+ const suite_title = pathParts[pathParts.length - 1];
244
+ const file = pathParts.slice(0, -1).join('/');
245
+ const title = testCase.method || testCase.name.split('.').pop();
246
+ const run_time = parseFloat(time) * 1000;
247
+ tests.push({
248
+ create: true,
249
+ stack,
250
+ message,
251
+ file,
252
+ status,
253
+ title,
254
+ suite_title,
255
+ run_time,
256
+ });
257
+ });
258
+ });
280
259
  });
281
- });
282
- });
283
-
284
- const hasFailures = tests.filter(t => t.status === STATUS.FAILED).length > 0;
285
- const status = hasFailures ? STATUS.FAILED : STATUS.PASSED;
286
-
287
- this.tests = tests;
288
-
289
- debug(tests);
290
-
291
- return {
292
- status,
293
- create_tests: true,
294
- name: 'xUnit',
295
- tests_count: tests.length,
296
- passed_count: tests.filter(t => t.status === STATUS.PASSED).length,
297
- failed_count: tests.filter(t => t.status === STATUS.FAILED).length,
298
- skipped_count: tests.filter(t => t.status === STATUS.SKIPPED).length,
299
- tests,
300
- };
301
- }
302
-
303
- calculateStats() {
304
- this.stats = {
305
- ...this.stats,
306
- status: 'passed',
307
- create_tests: true,
308
- tests_count: 0,
309
- passed_count: 0,
310
- failed_count: 0,
311
- skipped_count: 0,
312
- };
313
- this.tests.forEach(t => {
314
- this.stats.tests_count++;
315
- if (t.status === 'passed') this.stats.passed_count++;
316
- if (t.status === 'failed') this.stats.failed_count++;
317
- });
318
- if (this.stats.failed_count) this.stats.status = 'failed';
319
-
320
- return this.stats;
321
- }
322
-
323
- fetchSourceCode() {
324
- this.tests.forEach(t => {
325
- try {
326
- const file = this.adapter.getFilePath(t);
327
- if (!file) return;
328
-
329
- if (!this.stats.language) {
330
- if (file.endsWith('.php')) this.stats.language = 'php';
331
- if (file.endsWith('.py')) this.stats.language = 'python';
332
- if (file.endsWith('.java')) this.stats.language = 'java';
333
- if (file.endsWith('.rb')) this.stats.language = 'ruby';
334
- if (file.endsWith('.js')) this.stats.language = 'js';
335
- if (file.endsWith('.ts')) this.stats.language = 'ts';
336
- }
337
-
338
- if (!fs.existsSync(file)) {
339
- debug('Failed to open file with the source code', file);
340
- return;
260
+ const hasFailures = tests.filter(t => t.status === constants_js_1.STATUS.FAILED).length > 0;
261
+ const status = hasFailures ? constants_js_1.STATUS.FAILED : constants_js_1.STATUS.PASSED;
262
+ this.tests = tests;
263
+ debug(tests);
264
+ return {
265
+ status,
266
+ create_tests: true,
267
+ name: 'xUnit',
268
+ tests_count: tests.length,
269
+ passed_count: tests.filter(t => t.status === constants_js_1.STATUS.PASSED).length,
270
+ failed_count: tests.filter(t => t.status === constants_js_1.STATUS.FAILED).length,
271
+ skipped_count: tests.filter(t => t.status === constants_js_1.STATUS.SKIPPED).length,
272
+ tests,
273
+ };
274
+ }
275
+ calculateStats() {
276
+ this.stats = {
277
+ ...this.stats,
278
+ detach: this.requestParams.detach,
279
+ status: 'passed',
280
+ create_tests: true,
281
+ tests_count: 0,
282
+ passed_count: 0,
283
+ failed_count: 0,
284
+ skipped_count: 0,
285
+ };
286
+ this.tests.forEach(t => {
287
+ this.stats.tests_count++;
288
+ if (t.status === 'passed')
289
+ this.stats.passed_count++;
290
+ if (t.status === 'failed')
291
+ this.stats.failed_count++;
292
+ });
293
+ if (this.stats.failed_count)
294
+ this.stats.status = 'failed';
295
+ return this.stats;
296
+ }
297
+ fetchSourceCode() {
298
+ this.tests.forEach(t => {
299
+ try {
300
+ const file = this.adapter.getFilePath(t);
301
+ if (!file)
302
+ return;
303
+ if (!this.stats.language) {
304
+ if (file.endsWith('.php'))
305
+ this.stats.language = 'php';
306
+ if (file.endsWith('.py'))
307
+ this.stats.language = 'python';
308
+ if (file.endsWith('.java'))
309
+ this.stats.language = 'java';
310
+ if (file.endsWith('.rb'))
311
+ this.stats.language = 'ruby';
312
+ if (file.endsWith('.js'))
313
+ this.stats.language = 'js';
314
+ if (file.endsWith('.ts'))
315
+ this.stats.language = 'ts';
316
+ }
317
+ if (!fs_1.default.existsSync(file)) {
318
+ debug('Failed to open file with the source code', file);
319
+ return;
320
+ }
321
+ const contents = fs_1.default.readFileSync(file).toString();
322
+ t.code = (0, utils_js_1.fetchSourceCode)(contents, { ...t, lang: this.stats.language });
323
+ if (t.code)
324
+ debug('Fetched code for test %s', t.title);
325
+ t.test_id = (0, utils_js_1.fetchIdFromCode)(t.code, { lang: this.stats.language });
326
+ if (t.test_id)
327
+ debug('Fetched test id %s for test %s', t.test_id, t.title);
328
+ }
329
+ catch (err) {
330
+ debug(err);
331
+ }
332
+ });
333
+ }
334
+ formatTests() {
335
+ this.tests.forEach(t => {
336
+ if (t.file) {
337
+ t.file = t.file.replace(process.cwd() + path_1.default.sep, '');
338
+ }
339
+ this.adapter.formatTest(t);
340
+ t.title = (0, utils_js_1.humanize)(t.title);
341
+ });
342
+ }
343
+ formatErrors() {
344
+ this.tests
345
+ .filter(t => !!t.stack)
346
+ .forEach(t => {
347
+ t.stack = this.formatStack(t);
348
+ t.message = this.adapter.formatMessage(t);
349
+ });
350
+ }
351
+ formatStack(t) {
352
+ const stack = this.adapter.formatStack(t);
353
+ const sourcePart = (0, utils_js_1.fetchSourceCodeFromStackTrace)(stack);
354
+ if (!sourcePart)
355
+ return stack;
356
+ const separator = picocolors_1.default.bold(picocolors_1.default.red('################[ Failure ]################'));
357
+ return `${stack}\n\n${separator}\n${(0, utils_js_1.fetchSourceCodeFromStackTrace)(stack)}`;
358
+ }
359
+ async uploadArtifacts() {
360
+ for (const test of this.tests.filter(t => !!t.stack)) {
361
+ let files = [];
362
+ if (test.files?.length)
363
+ files = test.files.map(f => path_1.default.join(process.cwd(), f));
364
+ files = [...files, ...(0, utils_js_1.fetchFilesFromStackTrace)(test.stack)];
365
+ if (!files.length)
366
+ continue;
367
+ const runId = this.runId || this.store.runId || Date.now().toString();
368
+ test.artifacts = await Promise.all(files.map(f => this.uploader.uploadFileByPath(f, [runId])));
369
+ console.log(constants_js_1.APP_PREFIX, `🗄️ Uploaded ${picocolors_1.default.bold(`${files.length} artifacts`)} for test ${test.title}`);
341
370
  }
342
- const contents = fs.readFileSync(file).toString();
343
- t.code = fetchSourceCode(contents, { ...t, lang: this.stats.language });
344
- if (t.code) debug('Fetched code for test %s', t.title);
345
- t.test_id = fetchIdFromCode(t.code, { lang: this.stats.language });
346
- if (t.test_id) debug('Fetched test id %s for test %s', t.test_id, t.title);
347
- } catch (err) {
348
- debug(err);
349
- }
350
- });
351
- }
352
-
353
- formatTests() {
354
- this.tests.forEach(t => {
355
- if (t.file) {
356
- t.file = t.file.replace(process.cwd() + path.sep, '');
357
- }
358
-
359
- this.adapter.formatTest(t);
360
-
361
- t.title = humanize(t.title);
362
- });
363
- }
364
-
365
- formatErrors() {
366
- this.tests
367
- .filter(t => !!t.stack)
368
- .forEach(t => {
369
- t.stack = this.formatStack(t);
370
- t.message = this.adapter.formatMessage(t);
371
- });
372
- }
373
-
374
- formatStack(t) {
375
- const stack = this.adapter.formatStack(t);
376
-
377
- const sourcePart = fetchSourceCodeFromStackTrace(stack);
378
-
379
- if (!sourcePart) return stack;
380
-
381
- const separator = chalk.bold.red('################[ Failure ]################');
382
-
383
- return `${stack}\n\n${separator}\n${fetchSourceCodeFromStackTrace(stack)}`;
384
- }
385
-
386
- async uploadArtifacts() {
387
- for (const test of this.tests.filter(t => !!t.stack)) {
388
- let files = [];
389
- if (test.files?.length) files = test.files.map(f => path.join(process.cwd(), f));
390
- files = [...files, ...fetchFilesFromStackTrace(test.stack)];
391
-
392
- if (!files.length) continue;
393
-
394
- const runId = this.runId || this.store.runId || Date.now().toString();
395
- test.artifacts = await Promise.all(files.map(f => this.uploader.uploadFileByPath(f, [runId])));
396
- console.log(APP_PREFIX, `🗄️ Uploaded ${chalk.bold(`${files.length} artifacts`)} for test ${test.title}`);
397
371
  }
398
- }
399
-
400
- async createRun() {
401
- const runParams = {
402
- api_key: this.requestParams.apiKey,
403
- title: this.requestParams.title,
404
- env: this.requestParams.env,
405
- group_title: this.requestParams.group_title,
406
- isBatchEnabled: this.requestParams.isBatchEnabled,
407
- };
408
-
409
- debug('Run', runParams);
410
-
411
- await Promise.all(this.pipes.map(p => p.createRun(runParams)));
412
-
413
- this.uploader.checkEnabled();
414
- }
415
-
416
- async uploadData() {
417
- await this.uploadArtifacts();
418
- this.calculateStats();
419
- this.connectAdapter();
420
- this.fetchSourceCode();
421
- this.formatErrors();
422
- this.formatTests();
423
-
424
-
425
- const dataString = {
426
- ...this.stats,
427
- detach: this.requestParams.detach,
428
- api_key: this.requestParams.apiKey,
429
- status: 'finished',
430
- duration: this.stats.duration,
431
- tests: this.tests,
432
- };
433
-
434
- debug('Uploading data', dataString);
435
-
436
- return Promise.all(this.pipes.map(p => p.finishRun(dataString)));
437
- }
438
-
439
- async _finishRun() {
440
- return Promise.all(this.pipes.map(p => p.finishRun({ status: 'finished' })));
441
- }
372
+ async createRun() {
373
+ const runParams = {
374
+ api_key: this.requestParams.apiKey,
375
+ title: this.requestParams.title,
376
+ env: this.requestParams.env,
377
+ group_title: this.requestParams.group_title,
378
+ isBatchEnabled: this.requestParams.isBatchEnabled,
379
+ };
380
+ debug('Run', runParams);
381
+ this.pipes = this.pipes || (await this.pipesPromise);
382
+ const run = await Promise.all(this.pipes.map(p => p.createRun(runParams)));
383
+ this.uploader.checkEnabled();
384
+ return run;
385
+ }
386
+ async uploadData() {
387
+ await this.uploadArtifacts();
388
+ this.calculateStats();
389
+ this.connectAdapter();
390
+ this.fetchSourceCode();
391
+ this.formatErrors();
392
+ this.formatTests();
393
+ const dataString = {
394
+ ...this.stats,
395
+ api_key: this.requestParams.apiKey,
396
+ status: 'finished',
397
+ duration: this.stats.duration,
398
+ tests: this.tests,
399
+ };
400
+ debug('Uploading data', dataString);
401
+ this.pipes = this.pipes || (await this.pipesPromise);
402
+ return Promise.all(this.pipes.map(p => p.finishRun(dataString)));
403
+ }
404
+ async _finishRun() {
405
+ this.pipes = this.pipes || (await this.pipesPromise);
406
+ return Promise.all(this.pipes.map(p => p.finishRun({ status: 'finished' })));
407
+ }
442
408
  }
443
-
444
409
  module.exports = XmlReader;
445
-
446
410
  function reduceTestCases(prev, item) {
447
- let testCases = item.testcase;
448
- if (!testCases) testCases = item['test-case'];
449
- if (!Array.isArray(testCases)) {
450
- testCases = [testCases];
451
- }
452
-
453
- // suite inside test case
454
- if (item['test-suite'] && item['test-suite']['test-case']) testCases.push(...item['test-suite']['test-case']);
455
-
456
- const suiteOutput = item['system-out'] || item.output || item.log || '';
457
- const suiteErr = item['system-err'] || item.output || item.log || '';
458
- testCases
459
- .filter(t => !!t)
460
- .forEach(testCaseItem => {
461
- const file = testCaseItem.file || item.filepath || '';
462
-
463
- let stack = '';
464
- let message = '';
465
- if (testCaseItem.error) stack = testCaseItem.error;
466
- if (testCaseItem.failure) stack = testCaseItem.failure;
467
- if (testCaseItem?.failure?.['stack-trace']) stack = testCaseItem.failure['stack-trace'];
468
- if (testCaseItem?.failure?.message) message = testCaseItem.failure.message;
469
- if (testCaseItem?.error?.message) message = testCaseItem.error.message;
470
-
471
- if (testCaseItem.failure && testCaseItem.failure['#text']) stack = testCaseItem.failure['#text'];
472
- if (testCaseItem.error && testCaseItem.error['#text']) stack = testCaseItem.error['#text'];
473
- if (!message) message = stack.trim().split('\n')[0];
474
-
475
- const isParametrized = item.type === 'ParameterizedMethod';
476
- const preferClassname = reduceOptions.preferClassname || isParametrized;
477
-
478
- // SpecFlow config
479
- let { title, tags } = fetchProperties(isParametrized ? item : testCaseItem);
480
- let example = null;
481
- const suiteTitle = preferClassname ? testCaseItem.classname : item.name || testCaseItem.classname;
482
-
483
- title ||= testCaseItem.name || testCaseItem.methodname || testCaseItem.classname;
484
- tags ||= [];
485
-
486
- const exampleMatches = testCaseItem.name?.match(/\S\((.*?)\)/);
487
- if (exampleMatches) {
488
- example = { ...exampleMatches[1].split(',').map(v => v.trim().replace(/[^\w\s-]/g, '')) };
489
- title = title.replace(/\(.*?\)/, '').trim();
490
- }
491
-
492
- // eslint-disable-next-line
493
- stack = `${
494
- testCaseItem['system-out'] || testCaseItem.output || testCaseItem.log || ''
495
- }\n\n${stack}\n\n${suiteOutput}\n\n${suiteErr}`.trim();
496
- const testId = fetchIdFromOutput(stack);
497
-
498
- let status = STATUS.PASSED.toString();
499
- if ('failure' in testCaseItem || 'error' in testCaseItem) status = STATUS.FAILED;
500
- if ('skipped' in testCaseItem) status = STATUS.SKIPPED;
501
-
502
- let rid = null;
503
- if (testCaseItem.id) rid = `${ridRunId}-${testCaseItem.id}`;
504
-
505
- prev.push({
506
- rid,
507
- file,
508
- stack,
509
- example,
510
- tags,
511
- create: true,
512
- test_id: testId,
513
- message,
514
- line: testCaseItem.lineno,
515
- // seconds are used in junit reports, but ms are used by testomatio
516
- run_time: parseFloat(testCaseItem.time || testCaseItem.duration) * 1000,
517
- status,
518
- title,
519
- suite_title: suiteTitle,
520
- });
411
+ let testCases = item.testcase;
412
+ if (!testCases)
413
+ testCases = item['test-case'];
414
+ if (!Array.isArray(testCases)) {
415
+ testCases = [testCases];
416
+ }
417
+ // suite inside test case
418
+ if (item['test-suite'] && item['test-suite']['test-case'])
419
+ testCases.push(...item['test-suite']['test-case']);
420
+ const suiteOutput = item['system-out'] || item.output || item.log || '';
421
+ const suiteErr = item['system-err'] || item.output || item.log || '';
422
+ testCases
423
+ .filter(t => !!t)
424
+ .forEach(testCaseItem => {
425
+ const file = testCaseItem.file || item.filepath || '';
426
+ let stack = '';
427
+ let message = '';
428
+ if (testCaseItem.error)
429
+ stack = testCaseItem.error;
430
+ if (testCaseItem.failure)
431
+ stack = testCaseItem.failure;
432
+ if (testCaseItem?.failure?.['stack-trace'])
433
+ stack = testCaseItem.failure['stack-trace'];
434
+ if (testCaseItem?.failure?.message)
435
+ message = testCaseItem.failure.message;
436
+ if (testCaseItem?.error?.message)
437
+ message = testCaseItem.error.message;
438
+ if (testCaseItem.failure && testCaseItem.failure['#text'])
439
+ stack = testCaseItem.failure['#text'];
440
+ if (testCaseItem.error && testCaseItem.error['#text'])
441
+ stack = testCaseItem.error['#text'];
442
+ if (!message)
443
+ message = stack.trim().split('\n')[0];
444
+ const isParametrized = item.type === 'ParameterizedMethod';
445
+ const preferClassname = reduceOptions.preferClassname || isParametrized;
446
+ // SpecFlow config
447
+ let { title, tags } = fetchProperties(isParametrized ? item : testCaseItem);
448
+ let example = null;
449
+ const suiteTitle = preferClassname ? testCaseItem.classname : item.name || testCaseItem.classname;
450
+ title ||= testCaseItem.name || testCaseItem.methodname || testCaseItem.classname;
451
+ tags ||= [];
452
+ const exampleMatches = testCaseItem.name?.match(/\S\((.*?)\)/);
453
+ if (exampleMatches) {
454
+ example = { ...exampleMatches[1].split(',').map(v => v.trim().replace(/[^\w\s-]/g, '')) };
455
+ title = title.replace(/\(.*?\)/, '').trim();
456
+ }
457
+ // eslint-disable-next-line
458
+ stack = `${testCaseItem['system-out'] || testCaseItem.output || testCaseItem.log || ''}\n\n${stack}\n\n${suiteOutput}\n\n${suiteErr}`.trim();
459
+ const testId = (0, utils_js_1.fetchIdFromOutput)(stack);
460
+ let status = constants_js_1.STATUS.PASSED.toString();
461
+ if ('failure' in testCaseItem || 'error' in testCaseItem)
462
+ status = constants_js_1.STATUS.FAILED;
463
+ if ('skipped' in testCaseItem)
464
+ status = constants_js_1.STATUS.SKIPPED;
465
+ let rid = null;
466
+ if (testCaseItem.id)
467
+ rid = `${ridRunId}-${testCaseItem.id}`;
468
+ prev.push({
469
+ rid,
470
+ file,
471
+ stack,
472
+ example,
473
+ tags,
474
+ create: true,
475
+ test_id: testId,
476
+ message,
477
+ line: testCaseItem.lineno,
478
+ // seconds are used in junit reports, but ms are used by testomatio
479
+ run_time: parseFloat(testCaseItem.time || testCaseItem.duration) * 1000,
480
+ status,
481
+ title,
482
+ suite_title: suiteTitle,
483
+ });
521
484
  });
522
- return prev;
485
+ return prev;
523
486
  }
524
-
525
487
  function processTestSuite(testsuite) {
526
- if (!testsuite) return [];
527
- if (testsuite.testsuite) return processTestSuite(testsuite.testsuite);
528
- if (testsuite['test-suite'] && !testsuite['test-case']) return processTestSuite(testsuite['test-suite']);
529
-
530
- let suites = testsuite;
531
- if (!Array.isArray(testsuite)) {
532
- suites = [testsuite];
533
- }
534
-
535
- const subSuites = suites.filter(s => s['test-suite'] && !testsuite['test-case']);
536
-
537
- return [...subSuites.map(s => processTestSuite(s['test-suite'])), ...suites.reduce(reduceTestCases, [])].flat();
488
+ if (!testsuite)
489
+ return [];
490
+ if (testsuite.testsuite)
491
+ return processTestSuite(testsuite.testsuite);
492
+ if (testsuite['test-suite'] && !testsuite['test-case'])
493
+ return processTestSuite(testsuite['test-suite']);
494
+ let suites = testsuite;
495
+ if (!Array.isArray(testsuite)) {
496
+ suites = [testsuite];
497
+ }
498
+ const subSuites = suites.filter(s => s['test-suite'] && !testsuite['test-case']);
499
+ return [...subSuites.map(s => processTestSuite(s['test-suite'])), ...suites.reduce(reduceTestCases, [])].flat();
538
500
  }
539
-
540
501
  function fetchProperties(item) {
541
- const tags = [];
542
- let title = '';
543
-
544
- if (!item.properties) return {};
545
-
546
- const prop = [item.properties?.property].flat().find(p => p.name === 'Description');
547
- if (prop) title = prop.value;
548
- [item.properties?.property]
549
- .flat()
550
- .filter(p => p.name === 'Category')
551
- .forEach(p => tags.push(p.value));
552
- return { title, tags };
502
+ const tags = [];
503
+ let title = '';
504
+ if (!item.properties)
505
+ return {};
506
+ const prop = [item.properties?.property].flat().find(p => p.name === 'Description');
507
+ if (prop)
508
+ title = prop.value;
509
+ [item.properties?.property]
510
+ .flat()
511
+ .filter(p => p.name === 'Category')
512
+ .forEach(p => tags.push(p.value));
513
+ return { title, tags };
553
514
  }