@testomatio/reporter 1.3.1-beta → 1.3.1-beta.1-exclude-skipped-tests
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/README.md +61 -54
- package/lib/adapter/codecept.js +96 -35
- package/lib/adapter/cucumber/current.js +19 -12
- package/lib/adapter/cucumber/legacy.js +7 -6
- package/lib/adapter/cucumber.js +2 -2
- package/lib/adapter/cypress-plugin/index.js +53 -26
- package/lib/adapter/jasmine.js +2 -2
- package/lib/adapter/jest.js +50 -17
- package/lib/adapter/mocha.js +110 -58
- package/lib/adapter/playwright.js +95 -33
- package/lib/adapter/webdriver.js +47 -2
- package/lib/bin/reportXml.js +22 -16
- package/lib/bin/startTest.js +27 -6
- package/lib/client.js +185 -62
- package/lib/config.js +34 -0
- package/lib/constants.js +32 -7
- package/lib/data-storage.js +203 -0
- package/lib/fileUploader.js +135 -54
- package/lib/junit-adapter/adapter.js +0 -2
- package/lib/junit-adapter/csharp.js +3 -4
- package/lib/junit-adapter/index.js +3 -3
- package/lib/junit-adapter/java.js +35 -17
- package/lib/junit-adapter/javascript.js +1 -2
- package/lib/junit-adapter/python.js +12 -14
- package/lib/junit-adapter/ruby.js +1 -2
- package/lib/pipe/csv.js +37 -31
- package/lib/pipe/github.js +27 -39
- package/lib/pipe/gitlab.js +22 -26
- package/lib/pipe/html.js +361 -0
- package/lib/pipe/index.js +3 -1
- package/lib/pipe/testomatio.js +337 -54
- package/lib/reporter-functions.js +46 -0
- package/lib/reporter.js +11 -9
- package/lib/services/artifacts.js +57 -0
- package/lib/services/index.js +13 -0
- package/lib/services/key-values.js +58 -0
- package/lib/services/logger.js +311 -0
- package/lib/template/emptyData.svg +23 -0
- package/lib/template/testomatio.hbs +1421 -0
- package/lib/utils/pipe_utils.js +129 -0
- package/lib/{util.js → utils/utils.js} +147 -17
- package/lib/xmlReader.js +218 -122
- package/package.json +17 -9
- package/lib/_ArtifactStorageOld.js +0 -142
- package/lib/artifactStorage.js +0 -25
- package/lib/dataStorage.js +0 -244
- package/lib/logger.js +0 -301
package/lib/xmlReader.js
CHANGED
|
@@ -1,78 +1,91 @@
|
|
|
1
1
|
const debug = require('debug')('@testomatio/reporter:xml');
|
|
2
|
-
const path = require(
|
|
2
|
+
const path = require('path');
|
|
3
3
|
const chalk = require('chalk');
|
|
4
|
-
const fs = require(
|
|
5
|
-
const { XMLParser } = require(
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const { XMLParser } = require('fast-xml-parser');
|
|
6
6
|
const { APP_PREFIX, STATUS } = require('./constants');
|
|
7
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
fetchFilesFromStackTrace,
|
|
9
|
+
fetchIdFromOutput,
|
|
10
|
+
fetchSourceCode,
|
|
11
|
+
fetchSourceCodeFromStackTrace,
|
|
12
|
+
fetchIdFromCode,
|
|
13
|
+
humanize,
|
|
14
|
+
} = require('./utils/utils');
|
|
8
15
|
const upload = require('./fileUploader');
|
|
9
16
|
const pipesFactory = require('./pipe');
|
|
10
17
|
const adapterFactory = require('./junit-adapter');
|
|
18
|
+
const config = require('./config');
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
const TESTOMATIO_URL = process.env.TESTOMATIO_URL || "https://app.testomat.io";
|
|
14
|
-
const TESTOMATIO = process.env.TESTOMATIO; // key?
|
|
20
|
+
const TESTOMATIO_URL = process.env.TESTOMATIO_URL || 'https://app.testomat.io';
|
|
15
21
|
const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN } = process.env;
|
|
16
22
|
|
|
17
23
|
const options = {
|
|
18
24
|
ignoreDeclaration: true,
|
|
19
25
|
ignoreAttributes: false,
|
|
20
26
|
alwaysCreateTextNode: false,
|
|
21
|
-
attributeNamePrefix:
|
|
27
|
+
attributeNamePrefix: '',
|
|
22
28
|
parseTagValue: true,
|
|
23
29
|
};
|
|
24
30
|
|
|
25
31
|
const reduceOptions = {};
|
|
26
32
|
|
|
27
33
|
class XmlReader {
|
|
28
|
-
|
|
29
34
|
constructor(opts = {}) {
|
|
30
35
|
this.requestParams = {
|
|
31
|
-
apiKey: opts.apiKey || TESTOMATIO,
|
|
36
|
+
apiKey: opts.apiKey || config.TESTOMATIO,
|
|
32
37
|
url: opts.url || TESTOMATIO_URL,
|
|
33
38
|
title: TESTOMATIO_TITLE,
|
|
34
39
|
env: TESTOMATIO_ENV,
|
|
35
40
|
group_title: TESTOMATIO_RUNGROUP_TITLE,
|
|
41
|
+
// batch uploading is implemented for xml already
|
|
42
|
+
isBatchEnabled: false,
|
|
36
43
|
};
|
|
37
44
|
this.runId = opts.runId || TESTOMATIO_RUN;
|
|
38
|
-
this.adapter = adapterFactory(
|
|
45
|
+
this.adapter = adapterFactory(opts.lang?.toLowerCase(), opts);
|
|
39
46
|
if (!this.adapter) throw new Error('XML adapter for this format not found');
|
|
40
47
|
|
|
41
48
|
this.opts = opts || {};
|
|
42
|
-
|
|
43
|
-
this.pipes = pipesFactory(opts, store);
|
|
49
|
+
this.store = {};
|
|
50
|
+
this.pipes = pipesFactory(opts, this.store);
|
|
44
51
|
|
|
45
52
|
this.parser = new XMLParser(options);
|
|
46
|
-
this.tests = []
|
|
47
|
-
this.stats = {}
|
|
53
|
+
this.tests = [];
|
|
54
|
+
this.stats = {};
|
|
48
55
|
this.stats.language = opts.lang?.toLowerCase();
|
|
49
|
-
this.filesToUpload = {}
|
|
56
|
+
this.filesToUpload = {};
|
|
50
57
|
|
|
51
58
|
this.version = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')).toString()).version;
|
|
52
|
-
console.log(APP_PREFIX, `Testomatio Reporter v${this.version}`);
|
|
59
|
+
console.log(APP_PREFIX, `Testomatio Reporter v${this.version}`);
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
connectAdapter() {
|
|
56
|
-
if (this.opts.javaTests)
|
|
57
|
-
|
|
63
|
+
if (this.opts.javaTests) {
|
|
64
|
+
this.adapter = adapterFactory('java', this.opts);
|
|
65
|
+
return this.adapter;
|
|
66
|
+
}
|
|
67
|
+
this.adapter = adapterFactory(this.stats.language, this.opts);
|
|
68
|
+
return this.adapter;
|
|
58
69
|
}
|
|
59
70
|
|
|
60
|
-
parse(fileName) {
|
|
71
|
+
parse(fileName) {
|
|
61
72
|
const xmlData = fs.readFileSync(path.resolve(fileName));
|
|
62
73
|
const jsonResult = this.parser.parse(xmlData);
|
|
63
74
|
let jsonSuite;
|
|
64
|
-
|
|
75
|
+
|
|
65
76
|
if (jsonResult.testsuites) {
|
|
66
77
|
jsonSuite = jsonResult.testsuites;
|
|
67
78
|
} else if (jsonResult.testsuite) {
|
|
68
79
|
jsonSuite = jsonResult;
|
|
69
80
|
} else if (jsonResult.TestRun) {
|
|
70
|
-
return this.processTRX(jsonResult);
|
|
81
|
+
return this.processTRX(jsonResult);
|
|
71
82
|
} else if (jsonResult['test-run']) {
|
|
72
83
|
return this.processNUnit(jsonResult['test-run']);
|
|
84
|
+
} else if (jsonResult.assemblies) {
|
|
85
|
+
return this.processXUnit(jsonResult.assemblies);
|
|
73
86
|
} else {
|
|
74
|
-
console.log(jsonResult)
|
|
75
|
-
throw new Error("Format can't be parsed")
|
|
87
|
+
console.log(jsonResult);
|
|
88
|
+
throw new Error("Format can't be parsed");
|
|
76
89
|
}
|
|
77
90
|
|
|
78
91
|
return this.processJUnit(jsonSuite);
|
|
@@ -83,9 +96,9 @@ class XmlReader {
|
|
|
83
96
|
|
|
84
97
|
reduceOptions.preferClassname = this.stats.language === 'python';
|
|
85
98
|
const resultTests = processTestSuite(testsuite);
|
|
86
|
-
|
|
99
|
+
|
|
87
100
|
const hasFailures = resultTests.filter(t => t.status === 'failed').length > 0;
|
|
88
|
-
const status =
|
|
101
|
+
const status = failures > 0 || errors > 0 || hasFailures ? 'failed' : 'passed';
|
|
89
102
|
|
|
90
103
|
this.tests = this.tests.concat(resultTests);
|
|
91
104
|
|
|
@@ -118,43 +131,43 @@ class XmlReader {
|
|
|
118
131
|
skipped_count: parseInt(inconclusive + skipped, 10),
|
|
119
132
|
tests: resultTests,
|
|
120
133
|
};
|
|
121
|
-
}
|
|
134
|
+
}
|
|
122
135
|
|
|
123
136
|
processTRX(jsonSuite) {
|
|
124
137
|
let defs = jsonSuite?.TestRun?.TestDefinitions?.UnitTest;
|
|
125
138
|
if (!Array.isArray(defs)) defs = [defs].filter(d => !!d);
|
|
126
139
|
|
|
127
|
-
const tests =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
const tests =
|
|
141
|
+
defs.map(td => {
|
|
142
|
+
const title = td.name.replace(/\(.*?\)/, '').trim();
|
|
143
|
+
let example = td.name.match(/\((.*?)\)/);
|
|
144
|
+
if (example) example = { ...example[1].split(',') };
|
|
145
|
+
const suite = td.TestMethod.className.split(', ')[0].split('.');
|
|
146
|
+
const suite_title = suite.pop();
|
|
147
|
+
return {
|
|
148
|
+
title,
|
|
149
|
+
example,
|
|
150
|
+
file: suite.join('/'),
|
|
151
|
+
description: td.Description,
|
|
152
|
+
suite_title,
|
|
153
|
+
id: td.Execution.id,
|
|
154
|
+
};
|
|
155
|
+
}) || [];
|
|
142
156
|
|
|
143
157
|
let result = jsonSuite?.TestRun?.Results?.UnitTestResult;
|
|
144
158
|
if (!Array.isArray(result)) result = [result].filter(d => !!d);
|
|
145
159
|
|
|
146
|
-
const results = result.map(td => ({
|
|
160
|
+
const results = result.map(td => ({
|
|
147
161
|
id: td.executionId,
|
|
148
162
|
// seconds are used in junit reports, but ms are used by testomatio
|
|
149
163
|
run_time: parseFloat(td.duration) * 1000,
|
|
150
|
-
status: td.outcome,
|
|
164
|
+
status: td.outcome,
|
|
151
165
|
stack: td.Output.StdOut,
|
|
152
|
-
files: td?.ResultFiles?.ResultFile?.map(rf => rf.path)
|
|
166
|
+
files: td?.ResultFiles?.ResultFile?.map(rf => rf.path),
|
|
153
167
|
}));
|
|
154
168
|
|
|
155
|
-
|
|
156
169
|
results.forEach(r => {
|
|
157
|
-
const test = tests.find(t => t.id === r.id) || {
|
|
170
|
+
const test = tests.find(t => t.id === r.id) || {};
|
|
158
171
|
r.suite_title = test.suite_title;
|
|
159
172
|
r.title = test.title?.trim();
|
|
160
173
|
if (test.code) r.code = test.code;
|
|
@@ -169,7 +182,7 @@ class XmlReader {
|
|
|
169
182
|
});
|
|
170
183
|
|
|
171
184
|
debug(results);
|
|
172
|
-
|
|
185
|
+
|
|
173
186
|
const counters = jsonSuite?.TestRun?.ResultSummary?.Counters || {};
|
|
174
187
|
|
|
175
188
|
const failed_count = parseInt(counters.failed, 10) + parseInt(counters.error, 10);
|
|
@@ -187,7 +200,79 @@ class XmlReader {
|
|
|
187
200
|
skipped_count: parseInt(counters.notExecuted, 10),
|
|
188
201
|
failed_count,
|
|
189
202
|
tests: results,
|
|
190
|
-
};
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
processXUnit(assemblies) {
|
|
207
|
+
const tests = [];
|
|
208
|
+
|
|
209
|
+
assemblies = Array.isArray(assemblies.assembly) ? assemblies.assembly : [assemblies.assembly];
|
|
210
|
+
|
|
211
|
+
assemblies.forEach(assembly => {
|
|
212
|
+
const { collection } = assembly;
|
|
213
|
+
|
|
214
|
+
const suites = Array.isArray(collection) ? collection : [collection];
|
|
215
|
+
|
|
216
|
+
suites.forEach(suite => {
|
|
217
|
+
const { test } = suite;
|
|
218
|
+
if (!test) return;
|
|
219
|
+
const cases = Array.isArray(test) ? test : [test];
|
|
220
|
+
cases.forEach(testCase => {
|
|
221
|
+
const { type, time, result } = testCase;
|
|
222
|
+
|
|
223
|
+
let message = '';
|
|
224
|
+
let stack = '';
|
|
225
|
+
|
|
226
|
+
if (testCase.failure) {
|
|
227
|
+
message = testCase.failure.message;
|
|
228
|
+
stack = testCase.failure['stack-trace'];
|
|
229
|
+
}
|
|
230
|
+
if (testCase.reason) {
|
|
231
|
+
message = testCase.reason.message;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
let status = STATUS.PASSED;
|
|
235
|
+
if (result === 'Pass') status = STATUS.PASSED;
|
|
236
|
+
if (result === 'Fail') status = STATUS.FAILED;
|
|
237
|
+
if (result === 'Skip') status = STATUS.SKIPPED;
|
|
238
|
+
|
|
239
|
+
const pathParts = type.split('.');
|
|
240
|
+
const suite_title = pathParts[pathParts.length - 1];
|
|
241
|
+
const file = pathParts.slice(0, -1).join('/');
|
|
242
|
+
const title = testCase.method || testCase.name.split('.').pop();
|
|
243
|
+
const run_time = parseFloat(time) * 1000;
|
|
244
|
+
|
|
245
|
+
tests.push({
|
|
246
|
+
create: true,
|
|
247
|
+
stack,
|
|
248
|
+
message,
|
|
249
|
+
file,
|
|
250
|
+
status,
|
|
251
|
+
title,
|
|
252
|
+
suite_title,
|
|
253
|
+
run_time,
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
const hasFailures = tests.filter(t => t.status === STATUS.FAILED).length > 0;
|
|
260
|
+
const status = hasFailures ? STATUS.FAILED : STATUS.PASSED;
|
|
261
|
+
|
|
262
|
+
this.tests = tests;
|
|
263
|
+
|
|
264
|
+
debug(tests);
|
|
265
|
+
|
|
266
|
+
return {
|
|
267
|
+
status,
|
|
268
|
+
create_tests: true,
|
|
269
|
+
name: 'xUnit',
|
|
270
|
+
tests_count: tests.length,
|
|
271
|
+
passed_count: tests.filter(t => t.status === STATUS.PASSED).length,
|
|
272
|
+
failed_count: tests.filter(t => t.status === STATUS.FAILED).length,
|
|
273
|
+
skipped_count: tests.filter(t => t.status === STATUS.SKIPPED).length,
|
|
274
|
+
tests,
|
|
275
|
+
};
|
|
191
276
|
}
|
|
192
277
|
|
|
193
278
|
calculateStats() {
|
|
@@ -199,12 +284,12 @@ class XmlReader {
|
|
|
199
284
|
passed_count: 0,
|
|
200
285
|
failed_count: 0,
|
|
201
286
|
skipped_count: 0,
|
|
202
|
-
}
|
|
287
|
+
};
|
|
203
288
|
this.tests.forEach(t => {
|
|
204
289
|
this.stats.tests_count++;
|
|
205
290
|
if (t.status === 'passed') this.stats.passed_count++;
|
|
206
291
|
if (t.status === 'failed') this.stats.failed_count++;
|
|
207
|
-
})
|
|
292
|
+
});
|
|
208
293
|
if (this.stats.failed_count) this.stats.status = 'failed';
|
|
209
294
|
|
|
210
295
|
return this.stats;
|
|
@@ -213,7 +298,7 @@ class XmlReader {
|
|
|
213
298
|
fetchSourceCode() {
|
|
214
299
|
this.tests.forEach(t => {
|
|
215
300
|
try {
|
|
216
|
-
const file = this.adapter.getFilePath(t)
|
|
301
|
+
const file = this.adapter.getFilePath(t);
|
|
217
302
|
if (!file) return;
|
|
218
303
|
|
|
219
304
|
if (!this.stats.language) {
|
|
@@ -221,14 +306,21 @@ class XmlReader {
|
|
|
221
306
|
if (file.endsWith('.py')) this.stats.language = 'python';
|
|
222
307
|
if (file.endsWith('.java')) this.stats.language = 'java';
|
|
223
308
|
if (file.endsWith('.rb')) this.stats.language = 'ruby';
|
|
224
|
-
if (file.endsWith('.js')) this.stats.language
|
|
309
|
+
if (file.endsWith('.js')) this.stats.language = 'js';
|
|
225
310
|
if (file.endsWith('.ts')) this.stats.language = 'ts';
|
|
226
311
|
}
|
|
227
312
|
|
|
313
|
+
if (!fs.existsSync(file)) {
|
|
314
|
+
debug('Failed to open file with the source code', file);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
228
317
|
const contents = fs.readFileSync(file).toString();
|
|
229
|
-
t.code = fetchSourceCode(contents, { ...t, lang: this.stats.language })
|
|
318
|
+
t.code = fetchSourceCode(contents, { ...t, lang: this.stats.language });
|
|
319
|
+
if (t.code) debug('Fetched code for test %s', t.title);
|
|
320
|
+
t.test_id = fetchIdFromCode(t.code, { lang: this.stats.language });
|
|
321
|
+
if (t.test_id) debug('Fetched test id %s for test %s', t.test_id, t.title);
|
|
230
322
|
} catch (err) {
|
|
231
|
-
debug(err)
|
|
323
|
+
debug(err);
|
|
232
324
|
}
|
|
233
325
|
});
|
|
234
326
|
}
|
|
@@ -236,32 +328,22 @@ class XmlReader {
|
|
|
236
328
|
formatTests() {
|
|
237
329
|
this.tests.forEach(t => {
|
|
238
330
|
if (t.file) {
|
|
239
|
-
t.file = t.file.replace(process.cwd() + path.sep, '')
|
|
331
|
+
t.file = t.file.replace(process.cwd() + path.sep, '');
|
|
240
332
|
}
|
|
241
333
|
|
|
242
|
-
this.adapter.formatTest(t)
|
|
243
|
-
|
|
244
|
-
t.title = t.title
|
|
245
|
-
// insert a space before all caps
|
|
246
|
-
.replace(/([A-Z])/g, ' $1')
|
|
247
|
-
// _ chars to spaces
|
|
248
|
-
.replace(/_/g, ' ')
|
|
249
|
-
// uppercase the first character
|
|
250
|
-
.replace(/^(.)|\s(.)/g, $1 => $1.toLowerCase())
|
|
334
|
+
this.adapter.formatTest(t);
|
|
251
335
|
|
|
252
|
-
|
|
253
|
-
.replace(/^test\s/, '')
|
|
254
|
-
.replace(/^should\s/, '')
|
|
255
|
-
.trim();
|
|
336
|
+
t.title = humanize(t.title);
|
|
256
337
|
});
|
|
257
338
|
}
|
|
258
339
|
|
|
259
340
|
formatErrors() {
|
|
260
|
-
this.tests
|
|
261
|
-
t
|
|
262
|
-
t
|
|
263
|
-
|
|
264
|
-
|
|
341
|
+
this.tests
|
|
342
|
+
.filter(t => !!t.stack)
|
|
343
|
+
.forEach(t => {
|
|
344
|
+
t.stack = this.formatStack(t);
|
|
345
|
+
t.message = this.adapter.formatMessage(t);
|
|
346
|
+
});
|
|
265
347
|
}
|
|
266
348
|
|
|
267
349
|
formatStack(t) {
|
|
@@ -279,10 +361,14 @@ class XmlReader {
|
|
|
279
361
|
async uploadArtifacts() {
|
|
280
362
|
for (const test of this.tests.filter(t => !!t.stack)) {
|
|
281
363
|
let files = [];
|
|
282
|
-
if (test.files?.length) files = test.files.map(f => path.join(process.cwd(), f))
|
|
364
|
+
if (test.files?.length) files = test.files.map(f => path.join(process.cwd(), f));
|
|
283
365
|
files = [...files, ...fetchFilesFromStackTrace(test.stack)];
|
|
284
|
-
|
|
285
|
-
|
|
366
|
+
|
|
367
|
+
if (!files.length) continue;
|
|
368
|
+
|
|
369
|
+
const runId = this.runId || this.store.runId || Date.now().toString();
|
|
370
|
+
test.artifacts = await Promise.all(files.map(f => upload.uploadFileByPath(f, runId)));
|
|
371
|
+
console.log(APP_PREFIX, `🗄️ Uploaded ${chalk.bold(`${files.length} artifacts`)} for test ${test.title}`);
|
|
286
372
|
}
|
|
287
373
|
}
|
|
288
374
|
|
|
@@ -292,9 +378,10 @@ class XmlReader {
|
|
|
292
378
|
title: this.requestParams.title,
|
|
293
379
|
env: this.requestParams.env,
|
|
294
380
|
group_title: this.requestParams.group_title,
|
|
295
|
-
|
|
381
|
+
isBatchEnabled: this.requestParams.isBatchEnabled,
|
|
382
|
+
};
|
|
296
383
|
|
|
297
|
-
debug(
|
|
384
|
+
debug('Run', runParams);
|
|
298
385
|
|
|
299
386
|
return Promise.all(this.pipes.map(p => p.createRun(runParams)));
|
|
300
387
|
}
|
|
@@ -307,12 +394,10 @@ class XmlReader {
|
|
|
307
394
|
this.formatErrors();
|
|
308
395
|
this.formatTests();
|
|
309
396
|
|
|
310
|
-
debug(
|
|
311
|
-
'Uploading data',
|
|
312
|
-
{
|
|
397
|
+
debug('Uploading data', {
|
|
313
398
|
...this.stats,
|
|
314
399
|
tests: this.tests,
|
|
315
|
-
})
|
|
400
|
+
});
|
|
316
401
|
|
|
317
402
|
const dataString = {
|
|
318
403
|
...this.stats,
|
|
@@ -323,59 +408,70 @@ class XmlReader {
|
|
|
323
408
|
|
|
324
409
|
return Promise.all(this.pipes.map(p => p.finishRun(dataString)));
|
|
325
410
|
}
|
|
411
|
+
|
|
412
|
+
async _finishRun() {
|
|
413
|
+
return Promise.all(this.pipes.map(p => p.finishRun({ status: 'finished' })));
|
|
414
|
+
}
|
|
326
415
|
}
|
|
327
416
|
|
|
328
417
|
module.exports = XmlReader;
|
|
329
418
|
|
|
330
|
-
|
|
331
419
|
function reduceTestCases(prev, item) {
|
|
332
420
|
let testCases = item.testcase;
|
|
333
421
|
if (!testCases) testCases = item['test-case'];
|
|
334
422
|
if (!Array.isArray(testCases)) {
|
|
335
|
-
testCases = [testCases]
|
|
423
|
+
testCases = [testCases];
|
|
336
424
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
425
|
+
const suiteOutput = item['system-out'] || item.output || item.log || '';
|
|
426
|
+
const suiteErr = item['system-err'] || item.output || item.log || '';
|
|
427
|
+
testCases
|
|
428
|
+
.filter(t => !!t)
|
|
429
|
+
.forEach(testCaseItem => {
|
|
430
|
+
const file = testCaseItem.file || item.filepath || '';
|
|
431
|
+
|
|
432
|
+
let stack = '';
|
|
433
|
+
let message = '';
|
|
434
|
+
if (testCaseItem.error) stack = testCaseItem.error;
|
|
435
|
+
if (testCaseItem.failure) stack = testCaseItem.failure;
|
|
436
|
+
if (testCaseItem?.failure?.['stack-trace']) stack = testCaseItem.failure['stack-trace'];
|
|
437
|
+
if (testCaseItem?.failure?.message) message = testCaseItem.failure.message;
|
|
438
|
+
if (testCaseItem?.error?.message) message = testCaseItem.error.message;
|
|
439
|
+
|
|
440
|
+
if (testCaseItem.failure && testCaseItem.failure['#text']) stack = testCaseItem.failure['#text'];
|
|
441
|
+
if (testCaseItem.error && testCaseItem.error['#text']) stack = testCaseItem.error['#text'];
|
|
442
|
+
if (!message) message = stack.trim().split('\n')[0];
|
|
443
|
+
|
|
444
|
+
// eslint-disable-next-line
|
|
445
|
+
stack = `${
|
|
446
|
+
testCaseItem['system-out'] || testCaseItem.output || testCaseItem.log || ''
|
|
447
|
+
}\n\n${stack}\n\n${suiteOutput}\n\n${suiteErr}`.trim();
|
|
448
|
+
const testId = fetchIdFromOutput(stack);
|
|
449
|
+
|
|
450
|
+
let status = STATUS.PASSED.toString();
|
|
451
|
+
if ('failure' in testCaseItem || 'error' in testCaseItem) status = STATUS.FAILED;
|
|
452
|
+
if ('skipped' in testCaseItem) status = STATUS.SKIPPED;
|
|
453
|
+
|
|
454
|
+
prev.push({
|
|
455
|
+
create: true,
|
|
456
|
+
file,
|
|
457
|
+
stack,
|
|
458
|
+
test_id: testId,
|
|
459
|
+
message,
|
|
460
|
+
line: testCaseItem.lineno,
|
|
461
|
+
// seconds are used in junit reports, but ms are used by testomatio
|
|
462
|
+
run_time: parseFloat(testCaseItem.time || testCaseItem.duration) * 1000,
|
|
463
|
+
status,
|
|
464
|
+
title: testCaseItem.name,
|
|
465
|
+
suite_title: reduceOptions.preferClassname ? testCaseItem.classname : item.name || testCaseItem.classname,
|
|
466
|
+
});
|
|
467
|
+
});
|
|
372
468
|
return prev;
|
|
373
469
|
}
|
|
374
470
|
|
|
375
471
|
function processTestSuite(testsuite) {
|
|
376
472
|
if (!testsuite) return [];
|
|
377
|
-
if (testsuite.testsuite) return processTestSuite(testsuite.testsuite)
|
|
378
|
-
if (testsuite['test-suite']) return processTestSuite(testsuite['test-suite'])
|
|
473
|
+
if (testsuite.testsuite) return processTestSuite(testsuite.testsuite);
|
|
474
|
+
if (testsuite['test-suite']) return processTestSuite(testsuite['test-suite']);
|
|
379
475
|
|
|
380
476
|
let suites = testsuite;
|
|
381
477
|
if (!Array.isArray(testsuite)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testomatio/reporter",
|
|
3
|
-
"version": "1.3.1-beta",
|
|
3
|
+
"version": "1.3.1-beta.1-exclude-skipped-tests",
|
|
4
4
|
"description": "Testomatio Reporter Client",
|
|
5
5
|
"main": "./lib/reporter.js",
|
|
6
6
|
"typings": "typings/index.d.ts",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"@aws-sdk/lib-storage": "^3.279.0",
|
|
13
13
|
"@octokit/rest": "^19.0.5",
|
|
14
14
|
"aws-sdk": "^2.1072.0",
|
|
15
|
-
"axios": "^
|
|
15
|
+
"axios": "^1.6.2",
|
|
16
|
+
"axios-retry": "^3.9.1",
|
|
16
17
|
"callsite-record": "^4.1.4",
|
|
17
18
|
"chalk": "^4.1.0",
|
|
18
19
|
"commander": "^4.1.1",
|
|
@@ -20,14 +21,17 @@
|
|
|
20
21
|
"debug": "^4.3.4",
|
|
21
22
|
"dotenv": "^16.0.1",
|
|
22
23
|
"fast-xml-parser": "^4.0.8",
|
|
23
|
-
"
|
|
24
|
+
"file-url": "3.0.0",
|
|
25
|
+
"glob": "^10.3",
|
|
26
|
+
"handlebars": "^4.7.8",
|
|
24
27
|
"has-flag": "^5.0.1",
|
|
25
28
|
"humanize-duration": "^3.27.3",
|
|
26
29
|
"is-valid-path": "^0.1.1",
|
|
27
30
|
"json-cycle": "^1.3.0",
|
|
28
|
-
"lodash": "^4.17.21",
|
|
29
31
|
"lodash.memoize": "^4.1.2",
|
|
30
32
|
"lodash.merge": "^4.6.2",
|
|
33
|
+
"minimatch": "^9.0.3",
|
|
34
|
+
"promise-retry": "^2.0.1",
|
|
31
35
|
"uuid": "^9.0.0"
|
|
32
36
|
},
|
|
33
37
|
"files": [
|
|
@@ -37,26 +41,28 @@
|
|
|
37
41
|
],
|
|
38
42
|
"scripts": {
|
|
39
43
|
"clear-exportdir": "rm -rf export/",
|
|
40
|
-
"pretty": "prettier --
|
|
44
|
+
"pretty": "npx prettier --debug-check --check .",
|
|
45
|
+
"pretty:fix": "prettier --write .",
|
|
41
46
|
"lint": "eslint lib",
|
|
42
47
|
"lint:fix": "eslint lib --fix",
|
|
48
|
+
"format": "npm run lint:fix && npm run pretty:fix",
|
|
43
49
|
"test": "mocha tests/**",
|
|
44
50
|
"init": "cd ./tests/adapter/examples/cucumber && npm i",
|
|
45
|
-
"test:unit": "mocha tests",
|
|
46
51
|
"test:adapter": "mocha './tests/adapter/index.test.js'",
|
|
47
52
|
"test:pipes": "mocha './tests/pipes/*_test.js'",
|
|
48
53
|
"test:adapter:jest:example": "jest './tests/adapter/examples/jest/index.test.js' --config='./tests/adapter/examples/jest/jest.config.js'",
|
|
49
54
|
"test:adapter:mocha:example": "mocha './tests/adapter/examples/mocha/index.test.js' --config='./tests/adapter/examples/mocha/mocha.config.js'",
|
|
50
55
|
"test:adapter:jasmine:example": "./tests/adapter/examples/jasmine/passReporterOpts.sh && jasmine './tests/adapter/examples/jasmine/index.test.js' --reporter=./../../../lib/adapter/jasmine.js",
|
|
51
56
|
"test:adapter:codecept:example": "codeceptjs run --config='./tests/adapter/examples/codecept/codecept.conf.js'",
|
|
52
|
-
"test:adapter:cucumber:example": "cd ./tests/adapter/examples/cucumber && npx cucumber-js"
|
|
57
|
+
"test:adapter:cucumber:example": "cd ./tests/adapter/examples/cucumber && npx cucumber-js",
|
|
58
|
+
"test:storage": "npx mocha tests-storage/artifact-storage.test.js && npx mocha tests-storage/data-storage.test.js && TESTOMATIO_INTERCEPT_CONSOLE_LOGS=true npx mocha tests-storage/logger.test.js && npx mocha tests-storage/logger-2.test.js && npx mocha tests-storage/reporter-functions.test.js"
|
|
53
59
|
},
|
|
54
60
|
"devDependencies": {
|
|
55
61
|
"@cucumber/cucumber": "^9.3.0",
|
|
56
62
|
"@redocly/cli": "^1.0.0-beta.125",
|
|
57
63
|
"@wdio/reporter": "^7.16.13",
|
|
58
64
|
"chai": "^4.3.6",
|
|
59
|
-
"codeceptjs": "
|
|
65
|
+
"codeceptjs": "latest",
|
|
60
66
|
"cucumber": "^6.0.7",
|
|
61
67
|
"eslint": "^8.7.0",
|
|
62
68
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
@@ -64,9 +70,11 @@
|
|
|
64
70
|
"eslint-plugin-import": "^2.25.4",
|
|
65
71
|
"jasmine": "^3.10.0",
|
|
66
72
|
"jest": "^27.4.7",
|
|
73
|
+
"jsdom": "^22.1.0",
|
|
67
74
|
"mocha": "^9.2.0",
|
|
68
75
|
"mock-http-server": "^1.4.5",
|
|
69
|
-
"
|
|
76
|
+
"pino": "^8.15.0",
|
|
77
|
+
"prettier": "^3.2.5",
|
|
70
78
|
"puppeteer": "^13.1.2"
|
|
71
79
|
},
|
|
72
80
|
"bin": {
|