@testomatio/reporter 0.8.0-beta.20 → 0.8.0-beta.30
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 +12 -0
- package/README.md +29 -1
- package/lib/adapter/codecept.js +1 -1
- package/lib/adapter/mocha.js +19 -4
- package/lib/adapter/playwright.js +1 -1
- package/lib/bin/reportXml.js +6 -2
- package/lib/client.js +17 -10
- package/lib/fileUploader.js +82 -49
- package/lib/pipe/csv.js +100 -92
- package/lib/pipe/github.js +117 -63
- package/lib/pipe/gitlab.js +75 -38
- package/lib/pipe/index.js +20 -12
- package/lib/pipe/testomatio.js +7 -5
- package/lib/util.js +9 -9
- package/lib/xmlReader.js +26 -16
- package/package.json +3 -2
- package/testcafe/index.js +0 -61
- package/testcafe/package-lock.json +0 -863
- package/testcafe/package.json +0 -14
package/lib/xmlReader.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const debug = require('debug')('@testomatio/reporter:xml');
|
|
1
2
|
const path = require("path");
|
|
2
3
|
const chalk = require('chalk');
|
|
3
4
|
const fs = require("fs");
|
|
@@ -119,7 +120,10 @@ class XmlReader {
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
processTRX(jsonSuite) {
|
|
122
|
-
|
|
123
|
+
let defs = jsonSuite?.TestRun?.TestDefinitions?.UnitTest;
|
|
124
|
+
if (!Array.isArray(defs)) defs = [defs].filter(d => !!d);
|
|
125
|
+
|
|
126
|
+
const tests = defs.map(td => {
|
|
123
127
|
const title = td.name.replace(/\(.*?\)/, '').trim();
|
|
124
128
|
let example = td.name.match(/\((.*?)\)/);
|
|
125
129
|
if (example) example = { ...example[1].split(',')};
|
|
@@ -134,15 +138,20 @@ class XmlReader {
|
|
|
134
138
|
}
|
|
135
139
|
}) || [];
|
|
136
140
|
|
|
137
|
-
|
|
141
|
+
let result = jsonSuite?.TestRun?.Results?.UnitTestResult;
|
|
142
|
+
if (!Array.isArray(result)) result = [result].filter(d => !!d);
|
|
143
|
+
|
|
144
|
+
const results = result.map(td => ({
|
|
138
145
|
id: td.executionId,
|
|
139
146
|
run_time: parseFloat(td.duration),
|
|
140
147
|
status: td.outcome,
|
|
141
|
-
stack: td.Output.StdOut
|
|
148
|
+
stack: td.Output.StdOut,
|
|
149
|
+
files: td?.ResultFiles?.ResultFile?.map(rf => rf.path)
|
|
142
150
|
}));
|
|
143
151
|
|
|
152
|
+
|
|
144
153
|
results.forEach(r => {
|
|
145
|
-
const test = tests.find(t => t.id === r.id) || {};
|
|
154
|
+
const test = tests.find(t => t.id === r.id) || { };
|
|
146
155
|
r.suite_title = test.suite_title;
|
|
147
156
|
r.title = test.title?.trim();
|
|
148
157
|
if (test.example) r.example = test.example;
|
|
@@ -153,6 +162,8 @@ class XmlReader {
|
|
|
153
162
|
if (r.status === 'Skipped') r.status = SKIPPED;
|
|
154
163
|
delete r.id;
|
|
155
164
|
});
|
|
165
|
+
|
|
166
|
+
debug(results);
|
|
156
167
|
|
|
157
168
|
const counters = jsonSuite?.TestRun?.ResultSummary?.Counters || {};
|
|
158
169
|
|
|
@@ -161,7 +172,7 @@ class XmlReader {
|
|
|
161
172
|
let status = PASSED;
|
|
162
173
|
if (failed_count > 0) status = FAILED;
|
|
163
174
|
|
|
164
|
-
this.tests = results;
|
|
175
|
+
this.tests = results.filter(t => !!t.title);
|
|
165
176
|
|
|
166
177
|
return {
|
|
167
178
|
status,
|
|
@@ -212,9 +223,7 @@ class XmlReader {
|
|
|
212
223
|
const contents = fs.readFileSync(file).toString();
|
|
213
224
|
t.code = fetchSourceCode(contents, { ...t, lang: this.stats.language })
|
|
214
225
|
} catch (err) {
|
|
215
|
-
|
|
216
|
-
console.log(err)
|
|
217
|
-
}
|
|
226
|
+
debug(err)
|
|
218
227
|
}
|
|
219
228
|
});
|
|
220
229
|
}
|
|
@@ -264,7 +273,8 @@ class XmlReader {
|
|
|
264
273
|
|
|
265
274
|
async uploadArtifacts() {
|
|
266
275
|
for (const test of this.tests.filter(t => !!t.stack)) {
|
|
267
|
-
const files = fetchFilesFromStackTrace(test.stack);
|
|
276
|
+
const files = [...test.files.map(f => path.join(process.cwd(), f)), ...fetchFilesFromStackTrace(test.stack)];
|
|
277
|
+
debug('Uploading files', files)
|
|
268
278
|
test.artifacts = await Promise.all(files.map(f => upload.uploadFileByPath(f, this.runId)));
|
|
269
279
|
}
|
|
270
280
|
}
|
|
@@ -277,7 +287,7 @@ class XmlReader {
|
|
|
277
287
|
group_title: this.requestParams.group_title,
|
|
278
288
|
};
|
|
279
289
|
|
|
280
|
-
|
|
290
|
+
debug("Run", runParams);
|
|
281
291
|
|
|
282
292
|
return Promise.all(this.pipes.map(p => p.createRun(runParams)));
|
|
283
293
|
}
|
|
@@ -290,12 +300,12 @@ class XmlReader {
|
|
|
290
300
|
this.formatErrors();
|
|
291
301
|
this.formatTests();
|
|
292
302
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
303
|
+
debug(
|
|
304
|
+
'Uploading data',
|
|
305
|
+
{
|
|
306
|
+
...this.stats,
|
|
307
|
+
tests: this.tests,
|
|
308
|
+
})
|
|
299
309
|
|
|
300
310
|
const dataString = {
|
|
301
311
|
...this.stats,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testomatio/reporter",
|
|
3
|
-
"version": "0.8.0-beta.
|
|
3
|
+
"version": "0.8.0-beta.30",
|
|
4
4
|
"description": "Testomatio Reporter Client",
|
|
5
5
|
"main": "./lib/reporter.js",
|
|
6
6
|
"repository": "git@github.com:testomatio/reporter.git",
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@octokit/rest": "^19.0.5",
|
|
11
11
|
"aws-sdk": "^2.1072.0",
|
|
12
|
+
"@aws-sdk/client-s3": "^3.279.0",
|
|
13
|
+
"@aws-sdk/lib-storage": "^3.279.0",
|
|
12
14
|
"axios": "^0.25.0",
|
|
13
15
|
"callsite-record": "^4.1.4",
|
|
14
16
|
"chalk": "^4.1.0",
|
|
@@ -16,7 +18,6 @@
|
|
|
16
18
|
"dotenv": "^16.0.1",
|
|
17
19
|
"fast-xml-parser": "^4.0.8",
|
|
18
20
|
"glob": "^8.0.3",
|
|
19
|
-
"got": "^11.8.3",
|
|
20
21
|
"has-flag": "^5.0.1",
|
|
21
22
|
"humanize-duration": "^3.27.3",
|
|
22
23
|
"is-valid-path": "^0.1.1",
|
package/testcafe/index.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const TestomatClient = require('@testomatio/reporter/lib/client');
|
|
2
|
-
const TRConstants = require('@testomatio/reporter/lib/constants');
|
|
3
|
-
const util = require('@testomatio/reporter/lib/util');
|
|
4
|
-
|
|
5
|
-
module.exports = () => {
|
|
6
|
-
const apiKey = process.env.TESTOMATIO;
|
|
7
|
-
let failed = false;
|
|
8
|
-
|
|
9
|
-
if (apiKey === '' || apiKey === undefined) {
|
|
10
|
-
throw new Error('Testomat.io API key cannot be empty');
|
|
11
|
-
}
|
|
12
|
-
const client = new TestomatClient({ apiKey });
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
reportTaskStart(startTime, userAgents) {
|
|
16
|
-
console.log('TestCafe started with: ', userAgents);
|
|
17
|
-
client.createRun();
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
reportFixtureStart(name) {
|
|
21
|
-
console.log(`Suite : ${name}`);
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
reportTestDone(name, testRunInfo) {
|
|
25
|
-
let status = TRConstants.PASSED;
|
|
26
|
-
let message = '';
|
|
27
|
-
|
|
28
|
-
if (testRunInfo.skipped) {
|
|
29
|
-
status = TRConstants.SKIPPED;
|
|
30
|
-
}
|
|
31
|
-
if (testRunInfo.errs.length) {
|
|
32
|
-
status = TRConstants.FAILED;
|
|
33
|
-
message = this.renderErrors(testRunInfo.errs);
|
|
34
|
-
failed = true;
|
|
35
|
-
}
|
|
36
|
-
console.log(` - ${name} : ${status}`);
|
|
37
|
-
client.addTestRun(util.parseTest(name), status, {
|
|
38
|
-
error: testRunInfo.errs.length ? testRunInfo.errs[0] : null,
|
|
39
|
-
message,
|
|
40
|
-
title: name,
|
|
41
|
-
time: testRunInfo.durationMs,
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
renderErrors(errors) {
|
|
46
|
-
let errorMessage = '';
|
|
47
|
-
errors.forEach((error, id) => {
|
|
48
|
-
errorMessage = `${errorMessage}${this.formatError(error, `${id + 1} `)}\n`;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
console.log(errorMessage);
|
|
52
|
-
return errorMessage.replace(util.ansiRegExp(), '');
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
reportTaskDone() {
|
|
56
|
-
const status = failed ? TRConstants.FAILED : TRConstants.PASSED;
|
|
57
|
-
console.log(`Status : ${status}`);
|
|
58
|
-
client.updateRunStatus(status);
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
};
|