@testomatio/reporter 2.7.4-beta.allure-1 → 2.7.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/README.md +9 -4
- package/lib/adapter/vitest.d.ts +22 -3
- package/lib/adapter/vitest.js +250 -26
- package/lib/bin/cli.js +0 -28
- package/lib/client.d.ts +2 -1
- package/lib/client.js +3 -2
- package/lib/junit-adapter/index.js +0 -4
- package/lib/pipe/bitbucket.js +16 -1
- package/lib/pipe/html.js +24 -5
- package/lib/template/testomatio.hbs +131 -20
- package/lib/utils/utils.js +0 -9
- package/lib/xmlReader.js +7 -5
- package/package.json +1 -1
- package/src/adapter/vitest.js +253 -26
- package/src/bin/cli.js +0 -35
- package/src/client.js +3 -2
- package/src/junit-adapter/index.js +0 -4
- package/src/pipe/bitbucket.js +23 -1
- package/src/pipe/html.js +24 -5
- package/src/template/testomatio.hbs +131 -20
- package/src/utils/utils.js +0 -5
- package/src/xmlReader.js +9 -6
- package/lib/allureReader.d.ts +0 -65
- package/lib/allureReader.js +0 -461
- package/lib/junit-adapter/kotlin.d.ts +0 -5
- package/lib/junit-adapter/kotlin.js +0 -46
- package/src/allureReader.js +0 -540
- package/src/junit-adapter/kotlin.js +0 -48
package/lib/allureReader.js
DELETED
|
@@ -1,461 +0,0 @@
|
|
|
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 glob_1 = require("glob");
|
|
11
|
-
const constants_js_1 = require("./constants.js");
|
|
12
|
-
const crypto_1 = require("crypto");
|
|
13
|
-
const url_1 = require("url");
|
|
14
|
-
const config_js_1 = require("./config.js");
|
|
15
|
-
const uploader_js_1 = require("./uploader.js");
|
|
16
|
-
const index_js_1 = require("./pipe/index.js");
|
|
17
|
-
const utils_js_1 = require("./utils/utils.js");
|
|
18
|
-
const index_js_2 = __importDefault(require("./junit-adapter/index.js"));
|
|
19
|
-
// @ts-ignore
|
|
20
|
-
const debug = (0, debug_1.default)('@testomatio/reporter:allure');
|
|
21
|
-
const TESTOMATIO_URL = process.env.TESTOMATIO_URL || 'https://app.testomat.io';
|
|
22
|
-
const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_SUITE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN } = process.env;
|
|
23
|
-
class AllureReader {
|
|
24
|
-
constructor(opts = {}) {
|
|
25
|
-
this.requestParams = {
|
|
26
|
-
apiKey: opts.apiKey || config_js_1.config.TESTOMATIO,
|
|
27
|
-
url: opts.url || TESTOMATIO_URL,
|
|
28
|
-
title: TESTOMATIO_TITLE,
|
|
29
|
-
env: TESTOMATIO_ENV,
|
|
30
|
-
group_title: TESTOMATIO_RUNGROUP_TITLE,
|
|
31
|
-
isBatchEnabled: true,
|
|
32
|
-
};
|
|
33
|
-
this.runId = opts.runId || TESTOMATIO_RUN;
|
|
34
|
-
this.opts = opts || {};
|
|
35
|
-
this.withPackage = opts.withPackage || false;
|
|
36
|
-
this.store = {};
|
|
37
|
-
this.pipesPromise = (0, index_js_1.pipesFactory)(opts, this.store);
|
|
38
|
-
this._tests = [];
|
|
39
|
-
this.stats = {};
|
|
40
|
-
this.suites = {};
|
|
41
|
-
this.uploader = new uploader_js_1.S3Uploader();
|
|
42
|
-
// Allure results already contain steps and stack traces for all tests,
|
|
43
|
-
// so enable passing them for passed tests by default
|
|
44
|
-
if (!process.env.TESTOMATIO_STACK_PASSED) {
|
|
45
|
-
process.env.TESTOMATIO_STACK_PASSED = '1';
|
|
46
|
-
}
|
|
47
|
-
if (!process.env.TESTOMATIO_STEPS_PASSED) {
|
|
48
|
-
process.env.TESTOMATIO_STEPS_PASSED = '1';
|
|
49
|
-
}
|
|
50
|
-
const packageJsonPath = path_1.default.resolve(__dirname, '..', 'package.json');
|
|
51
|
-
this.version = JSON.parse(fs_1.default.readFileSync(packageJsonPath).toString()).version;
|
|
52
|
-
console.log(constants_js_1.APP_PREFIX, `Testomatio Reporter v${this.version}`);
|
|
53
|
-
}
|
|
54
|
-
get tests() {
|
|
55
|
-
return this._tests;
|
|
56
|
-
}
|
|
57
|
-
set tests(value) {
|
|
58
|
-
this._tests = value;
|
|
59
|
-
}
|
|
60
|
-
async createRun() {
|
|
61
|
-
const runParams = {
|
|
62
|
-
api_key: this.requestParams.apiKey,
|
|
63
|
-
title: this.requestParams.title,
|
|
64
|
-
env: this.requestParams.env,
|
|
65
|
-
group_title: this.requestParams.group_title,
|
|
66
|
-
isBatchEnabled: this.requestParams.isBatchEnabled,
|
|
67
|
-
};
|
|
68
|
-
debug('Run', runParams);
|
|
69
|
-
this.pipes = this.pipes || (await this.pipesPromise);
|
|
70
|
-
const run = await Promise.all(this.pipes.map(p => p.createRun(runParams)));
|
|
71
|
-
this.uploader.checkEnabled();
|
|
72
|
-
return run;
|
|
73
|
-
}
|
|
74
|
-
parse(resultsPattern) {
|
|
75
|
-
this._tests = [];
|
|
76
|
-
let pattern = resultsPattern;
|
|
77
|
-
// Auto-append wildcard if pattern refers to a directory (like XML command does)
|
|
78
|
-
if (!pattern.endsWith('.json') && !pattern.includes('*')) {
|
|
79
|
-
if (pattern.endsWith('/') || (fs_1.default.existsSync(pattern) && fs_1.default.statSync(pattern).isDirectory())) {
|
|
80
|
-
pattern = pattern.replace(/\/+$/, '') + '/*-result.json';
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
pattern += '*-result.json';
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const resultsDir = path_1.default.dirname(pattern);
|
|
87
|
-
console.log(constants_js_1.APP_PREFIX, `Scanning for Allure results in: ${resultsDir}`);
|
|
88
|
-
console.log(constants_js_1.APP_PREFIX, `Using pattern: ${pattern}`);
|
|
89
|
-
const resultFiles = glob_1.glob.sync(pattern);
|
|
90
|
-
const containerFiles = glob_1.glob.sync(pattern.replace('*-result.json', '*-container.json'));
|
|
91
|
-
if (resultFiles.length === 0 && containerFiles.length === 0) {
|
|
92
|
-
throw new Error(`No Allure result files found matching pattern: ${pattern}`);
|
|
93
|
-
}
|
|
94
|
-
console.log(constants_js_1.APP_PREFIX, `Found ${resultFiles.length} result files and ${containerFiles.length} container files`);
|
|
95
|
-
this.parseContainerFiles(containerFiles);
|
|
96
|
-
// Store all tests temporarily for deduplication by historyId
|
|
97
|
-
const allTests = [];
|
|
98
|
-
for (const file of resultFiles) {
|
|
99
|
-
const fullPath = file;
|
|
100
|
-
const fileDir = path_1.default.dirname(file);
|
|
101
|
-
try {
|
|
102
|
-
const resultData = JSON.parse(fs_1.default.readFileSync(fullPath, 'utf8'));
|
|
103
|
-
const test = this.processAllureResult(resultData, fileDir);
|
|
104
|
-
if (test) {
|
|
105
|
-
test._historyId = resultData.historyId;
|
|
106
|
-
test._stop = resultData.stop || 0;
|
|
107
|
-
allTests.push(test);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
console.warn(constants_js_1.APP_PREFIX, `Failed to parse ${file}:`, err.message);
|
|
112
|
-
debug('Parse error:', err);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const attemptsMap = new Map();
|
|
116
|
-
for (const test of allTests) {
|
|
117
|
-
const historyId = test._historyId || test.rid;
|
|
118
|
-
if (!attemptsMap.has(historyId)) {
|
|
119
|
-
attemptsMap.set(historyId, []);
|
|
120
|
-
}
|
|
121
|
-
attemptsMap.get(historyId).push(test);
|
|
122
|
-
}
|
|
123
|
-
const uniqueTestsMap = new Map();
|
|
124
|
-
for (const [historyId, attempts] of attemptsMap) {
|
|
125
|
-
uniqueTestsMap.set(historyId, this.combineRetryAttempts(attempts));
|
|
126
|
-
}
|
|
127
|
-
// Convert map to array and clean up internal fields
|
|
128
|
-
this._tests = Array.from(uniqueTestsMap.values()).map(t => {
|
|
129
|
-
delete t._historyId;
|
|
130
|
-
delete t._stop;
|
|
131
|
-
return t;
|
|
132
|
-
});
|
|
133
|
-
console.log(constants_js_1.APP_PREFIX, `Processed ${this._tests.length} unique tests (from ${allTests.length} result files)`);
|
|
134
|
-
return this.calculateStats();
|
|
135
|
-
}
|
|
136
|
-
parseContainerFiles(containerFiles) {
|
|
137
|
-
for (const file of containerFiles) {
|
|
138
|
-
try {
|
|
139
|
-
const data = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
|
|
140
|
-
if (data.name && data.children) {
|
|
141
|
-
data.children.forEach(uuid => {
|
|
142
|
-
this.suites[uuid] = data.name;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (err) {
|
|
147
|
-
debug('Failed to parse container file:', file, err.message);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
debug('Parsed suites:', this.suites);
|
|
151
|
-
}
|
|
152
|
-
processAllureResult(result, resultsDir) {
|
|
153
|
-
const test = {
|
|
154
|
-
rid: result.uuid || (0, crypto_1.randomUUID)(),
|
|
155
|
-
title: result.name || 'Unknown test',
|
|
156
|
-
status: this.mapStatus(result.status),
|
|
157
|
-
suite_title: this.extractSuiteTitle(result),
|
|
158
|
-
file: this.extractFile(result),
|
|
159
|
-
run_time: this.calculateRunTime(result),
|
|
160
|
-
steps: this.convertSteps(result.steps || []),
|
|
161
|
-
message: result.statusDetails?.message || '',
|
|
162
|
-
stack: result.statusDetails?.trace || '',
|
|
163
|
-
meta: this.extractMeta(result),
|
|
164
|
-
links: this.extractLinks(result),
|
|
165
|
-
artifacts: [],
|
|
166
|
-
create: true,
|
|
167
|
-
overwrite: true,
|
|
168
|
-
};
|
|
169
|
-
// Add description if present
|
|
170
|
-
if (result.description) {
|
|
171
|
-
test.description = result.description;
|
|
172
|
-
}
|
|
173
|
-
if (result.parameters && result.parameters.length > 0) {
|
|
174
|
-
test.example = this.convertParameters(result.parameters);
|
|
175
|
-
}
|
|
176
|
-
if (result.attachments && result.attachments.length > 0) {
|
|
177
|
-
const attachments = result.attachments
|
|
178
|
-
.map(att => {
|
|
179
|
-
const fullPath = path_1.default.join(resultsDir, att.source);
|
|
180
|
-
if (fs_1.default.existsSync(fullPath)) {
|
|
181
|
-
return fullPath;
|
|
182
|
-
}
|
|
183
|
-
debug('Attachment file not found:', fullPath);
|
|
184
|
-
return null;
|
|
185
|
-
})
|
|
186
|
-
.filter(Boolean);
|
|
187
|
-
if (attachments.length > 0) {
|
|
188
|
-
test.files = attachments;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return test;
|
|
192
|
-
}
|
|
193
|
-
mapStatus(status) {
|
|
194
|
-
const statusMap = {
|
|
195
|
-
passed: 'passed',
|
|
196
|
-
failed: 'failed',
|
|
197
|
-
broken: 'failed',
|
|
198
|
-
skipped: 'skipped',
|
|
199
|
-
pending: 'skipped',
|
|
200
|
-
};
|
|
201
|
-
return statusMap[status] || 'failed';
|
|
202
|
-
}
|
|
203
|
-
extractSuiteTitle(result) {
|
|
204
|
-
const labels = result.labels || [];
|
|
205
|
-
// Only use suite label for suite_title
|
|
206
|
-
// Epic and Feature are sent as separate labels in meta
|
|
207
|
-
const suiteLabel = labels.find(l => l.name === 'suite')?.value;
|
|
208
|
-
if (suiteLabel) {
|
|
209
|
-
return this.stripNamespace(suiteLabel);
|
|
210
|
-
}
|
|
211
|
-
// Fallback to parentSuite or subSuite if no suite label
|
|
212
|
-
const parentSuite = labels.find(l => l.name === 'parentSuite')?.value;
|
|
213
|
-
const subSuite = labels.find(l => l.name === 'subSuite')?.value;
|
|
214
|
-
if (parentSuite && subSuite) {
|
|
215
|
-
return `${parentSuite} / ${subSuite}`;
|
|
216
|
-
}
|
|
217
|
-
if (parentSuite)
|
|
218
|
-
return parentSuite;
|
|
219
|
-
if (subSuite)
|
|
220
|
-
return subSuite;
|
|
221
|
-
return 'Default Suite';
|
|
222
|
-
}
|
|
223
|
-
stripNamespace(suiteName) {
|
|
224
|
-
if (suiteName && suiteName.includes('.')) {
|
|
225
|
-
return suiteName.split('.').pop();
|
|
226
|
-
}
|
|
227
|
-
return suiteName;
|
|
228
|
-
}
|
|
229
|
-
extractFile(result) {
|
|
230
|
-
const labels = result.labels || [];
|
|
231
|
-
const packageLabel = labels.find(l => l.name === 'package')?.value;
|
|
232
|
-
const testClassLabel = labels.find(l => l.name === 'testClass')?.value;
|
|
233
|
-
if (!packageLabel) {
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
const ext = this.getFileExtension(result);
|
|
237
|
-
let className;
|
|
238
|
-
if (testClassLabel) {
|
|
239
|
-
className = testClassLabel.split('.').pop();
|
|
240
|
-
}
|
|
241
|
-
else if (result.fullName) {
|
|
242
|
-
const fullNameParts = result.fullName.split('.');
|
|
243
|
-
className = fullNameParts[fullNameParts.length - 2] || fullNameParts[fullNameParts.length - 1];
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
if (this.withPackage) {
|
|
249
|
-
const parts = packageLabel.split('.');
|
|
250
|
-
return `${parts.join('/')}/${className}.${ext}`;
|
|
251
|
-
}
|
|
252
|
-
return `${className}.${ext}`;
|
|
253
|
-
}
|
|
254
|
-
getFileExtension(result) {
|
|
255
|
-
const labels = result.labels || [];
|
|
256
|
-
const languageLabel = labels.find(l => l.name === 'language')?.value;
|
|
257
|
-
const extMap = {
|
|
258
|
-
java: 'java',
|
|
259
|
-
kotlin: 'kt',
|
|
260
|
-
javascript: 'js',
|
|
261
|
-
typescript: 'ts',
|
|
262
|
-
python: 'py',
|
|
263
|
-
ruby: 'rb',
|
|
264
|
-
'c#': 'cs',
|
|
265
|
-
php: 'php',
|
|
266
|
-
};
|
|
267
|
-
return extMap[languageLabel?.toLowerCase()] || 'java';
|
|
268
|
-
}
|
|
269
|
-
extractMeta(result) {
|
|
270
|
-
const labels = result.labels || [];
|
|
271
|
-
const excludedLabels = [
|
|
272
|
-
'suite', 'package', 'parentSuite', 'subSuite',
|
|
273
|
-
'testClass', 'testMethod', 'epic', 'feature',
|
|
274
|
-
];
|
|
275
|
-
const meta = {};
|
|
276
|
-
labels.forEach(label => {
|
|
277
|
-
if (!excludedLabels.includes(label.name)) {
|
|
278
|
-
meta[label.name] = label.value;
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
return meta;
|
|
282
|
-
}
|
|
283
|
-
extractLinks(result) {
|
|
284
|
-
const labels = result.labels || [];
|
|
285
|
-
const links = [];
|
|
286
|
-
const epicLabel = labels.find(l => l.name === 'epic');
|
|
287
|
-
const featureLabel = labels.find(l => l.name === 'feature');
|
|
288
|
-
if (epicLabel?.value) {
|
|
289
|
-
links.push({ label: `epic:${epicLabel.value}` });
|
|
290
|
-
}
|
|
291
|
-
if (featureLabel?.value) {
|
|
292
|
-
links.push({ label: `feature:${featureLabel.value}` });
|
|
293
|
-
}
|
|
294
|
-
return links.length > 0 ? links : undefined;
|
|
295
|
-
}
|
|
296
|
-
convertSteps(steps, depth = 0) {
|
|
297
|
-
if (depth >= 10)
|
|
298
|
-
return null;
|
|
299
|
-
return steps
|
|
300
|
-
.map(step => {
|
|
301
|
-
const convertedStep = {
|
|
302
|
-
category: 'user',
|
|
303
|
-
title: step.name || step.title || 'Unknown step',
|
|
304
|
-
duration: this.calculateRunTime(step),
|
|
305
|
-
steps: this.convertSteps(step.steps || [], depth + 1),
|
|
306
|
-
};
|
|
307
|
-
if (convertedStep.steps && convertedStep.steps.length === 0) {
|
|
308
|
-
delete convertedStep.steps;
|
|
309
|
-
}
|
|
310
|
-
if (convertedStep.duration === 0) {
|
|
311
|
-
delete convertedStep.duration;
|
|
312
|
-
}
|
|
313
|
-
return convertedStep;
|
|
314
|
-
})
|
|
315
|
-
.filter(Boolean);
|
|
316
|
-
}
|
|
317
|
-
calculateRunTime(item) {
|
|
318
|
-
if (item.start && item.stop) {
|
|
319
|
-
const durationMs = item.stop - item.start;
|
|
320
|
-
return durationMs / 1000;
|
|
321
|
-
}
|
|
322
|
-
return null;
|
|
323
|
-
}
|
|
324
|
-
convertParameters(parameters) {
|
|
325
|
-
const example = {};
|
|
326
|
-
parameters.forEach(param => {
|
|
327
|
-
if (param.name) {
|
|
328
|
-
example[param.name] = param.value;
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
return example;
|
|
332
|
-
}
|
|
333
|
-
combineRetryAttempts(attempts) {
|
|
334
|
-
attempts.sort((a, b) => (a._stop || 0) - (b._stop || 0));
|
|
335
|
-
const finalTest = attempts[attempts.length - 1];
|
|
336
|
-
const retryCount = attempts.length - 1;
|
|
337
|
-
if (retryCount > 0) {
|
|
338
|
-
finalTest.retries = retryCount;
|
|
339
|
-
}
|
|
340
|
-
const failedAttempts = attempts.filter(t => t.status === 'failed');
|
|
341
|
-
if (failedAttempts.length === 0) {
|
|
342
|
-
return finalTest;
|
|
343
|
-
}
|
|
344
|
-
const failureMessages = [];
|
|
345
|
-
const failureStacks = [];
|
|
346
|
-
for (const failed of failedAttempts) {
|
|
347
|
-
const attemptNum = attempts.indexOf(failed) + 1;
|
|
348
|
-
if (failed.message) {
|
|
349
|
-
failureMessages.push(`[Attempt ${attemptNum}] ${failed.message}`);
|
|
350
|
-
}
|
|
351
|
-
if (failed.stack) {
|
|
352
|
-
failureStacks.push(`\n--- Attempt ${attemptNum} ---\n${failed.stack}`);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
if (failureMessages.length > 0) {
|
|
356
|
-
finalTest.message = failureMessages.join('\n');
|
|
357
|
-
}
|
|
358
|
-
if (failureStacks.length > 0) {
|
|
359
|
-
finalTest.stack = failureStacks.join('\n');
|
|
360
|
-
}
|
|
361
|
-
if (finalTest.status === 'passed') {
|
|
362
|
-
finalTest.status = 'failed';
|
|
363
|
-
const retryMsg = `Test passed after ${failedAttempts.length} retries. Previous failures:\n`;
|
|
364
|
-
finalTest.message = retryMsg + finalTest.message;
|
|
365
|
-
}
|
|
366
|
-
return finalTest;
|
|
367
|
-
}
|
|
368
|
-
calculateStats() {
|
|
369
|
-
this.stats = {
|
|
370
|
-
create_tests: true,
|
|
371
|
-
tests_count: this._tests.length,
|
|
372
|
-
passed_count: 0,
|
|
373
|
-
failed_count: 0,
|
|
374
|
-
skipped_count: 0,
|
|
375
|
-
duration: 0,
|
|
376
|
-
status: 'passed',
|
|
377
|
-
tests: this._tests,
|
|
378
|
-
};
|
|
379
|
-
this._tests.forEach(t => {
|
|
380
|
-
if (t.status === 'passed')
|
|
381
|
-
this.stats.passed_count++;
|
|
382
|
-
if (t.status === 'failed')
|
|
383
|
-
this.stats.failed_count++;
|
|
384
|
-
if (t.status === 'skipped')
|
|
385
|
-
this.stats.skipped_count++;
|
|
386
|
-
});
|
|
387
|
-
this.stats.duration = this._tests.reduce((acc, t) => acc + (t.run_time || 0), 0);
|
|
388
|
-
if (this.stats.failed_count)
|
|
389
|
-
this.stats.status = 'failed';
|
|
390
|
-
debug('Stats:', this.stats);
|
|
391
|
-
return this.stats;
|
|
392
|
-
}
|
|
393
|
-
fetchSourceCode() {
|
|
394
|
-
const adapter = this.adapter || (0, index_js_2.default)(this.getLanguage(), this.opts);
|
|
395
|
-
this._tests.forEach(t => {
|
|
396
|
-
try {
|
|
397
|
-
let filePath = t.file;
|
|
398
|
-
if (adapter && adapter.getFilePath) {
|
|
399
|
-
filePath = adapter.getFilePath(t);
|
|
400
|
-
}
|
|
401
|
-
if (!filePath)
|
|
402
|
-
return;
|
|
403
|
-
if (!fs_1.default.existsSync(filePath)) {
|
|
404
|
-
debug('Source file not found:', filePath);
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
const contents = fs_1.default.readFileSync(filePath).toString();
|
|
408
|
-
const code = (0, utils_js_1.fetchSourceCode)(contents, { ...t, lang: this.getLanguage() });
|
|
409
|
-
if (code) {
|
|
410
|
-
t.code = code;
|
|
411
|
-
debug('Fetched code for test %s', t.title);
|
|
412
|
-
}
|
|
413
|
-
const testId = (0, utils_js_1.fetchIdFromCode)(contents, { lang: this.getLanguage() });
|
|
414
|
-
if (testId) {
|
|
415
|
-
t.test_id = testId;
|
|
416
|
-
debug('Fetched test id %s for test %s', testId, t.title);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
catch (err) {
|
|
420
|
-
debug('Failed to fetch source code:', err.message);
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
getLanguage() {
|
|
425
|
-
if (this._tests.length === 0)
|
|
426
|
-
return null;
|
|
427
|
-
return this._tests[0].meta?.language || this.opts.lang;
|
|
428
|
-
}
|
|
429
|
-
async uploadArtifacts() {
|
|
430
|
-
for (const test of this._tests.filter(t => t.files && t.files.length > 0)) {
|
|
431
|
-
const runId = this.runId || this.store.runId || Date.now().toString();
|
|
432
|
-
const artifacts = await Promise.all(test.files.map(f => this.uploader.uploadFileByPath(f, [runId, test.rid, path_1.default.basename(f)])));
|
|
433
|
-
test.artifacts = artifacts.filter(a => a && a.link).map(a => a.link);
|
|
434
|
-
delete test.files;
|
|
435
|
-
if (test.artifacts.length > 0) {
|
|
436
|
-
console.log(constants_js_1.APP_PREFIX, `🗄️ Uploaded ${picocolors_1.default.bold(`${test.artifacts.length} artifacts`)} for test ${test.title}`);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
async uploadData() {
|
|
441
|
-
await this.uploadArtifacts();
|
|
442
|
-
this.calculateStats();
|
|
443
|
-
this.fetchSourceCode();
|
|
444
|
-
this.pipes = this.pipes || (await this.pipesPromise);
|
|
445
|
-
// Upload tests individually via addTest (like XML reader does)
|
|
446
|
-
// so each pipe processes them through its own pipeline
|
|
447
|
-
for (const test of this._tests) {
|
|
448
|
-
await Promise.all(this.pipes.map(p => p.addTest(test)));
|
|
449
|
-
}
|
|
450
|
-
// Flush any batched tests
|
|
451
|
-
await Promise.all(this.pipes.map(p => p.sync()));
|
|
452
|
-
debug('Uploaded %d tests, finishing run', this._tests.length);
|
|
453
|
-
const finishData = {
|
|
454
|
-
api_key: this.requestParams.apiKey,
|
|
455
|
-
status: 'finished',
|
|
456
|
-
duration: this.stats.duration,
|
|
457
|
-
};
|
|
458
|
-
return Promise.all(this.pipes.map(p => p.finishRun(finishData)));
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
module.exports = AllureReader;
|
|
@@ -1,46 +0,0 @@
|
|
|
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 path_1 = __importDefault(require("path"));
|
|
7
|
-
const adapter_js_1 = __importDefault(require("./adapter.js"));
|
|
8
|
-
class KotlinAdapter extends adapter_js_1.default {
|
|
9
|
-
getFilePath(t) {
|
|
10
|
-
const fileName = namespaceToFileName(t.suite_title);
|
|
11
|
-
return this.opts.javaTests + path_1.default.sep + fileName;
|
|
12
|
-
}
|
|
13
|
-
formatTest(t) {
|
|
14
|
-
const fileParts = t.suite_title.split('.');
|
|
15
|
-
t.file = namespaceToFileName(t.suite_title);
|
|
16
|
-
t.title = t.title.split('(')[0];
|
|
17
|
-
// detect params
|
|
18
|
-
const paramMatches = t.title.match(/\[(.*?)\]/g);
|
|
19
|
-
if (paramMatches) {
|
|
20
|
-
const params = paramMatches.map((_match, index) => `param${index + 1}`);
|
|
21
|
-
if (params.length === 1)
|
|
22
|
-
params[0] = 'param';
|
|
23
|
-
let paramIndex = 0;
|
|
24
|
-
t.title = t.title.replace(/: \[(.*?)\]/g, () => {
|
|
25
|
-
if (params.length < 2)
|
|
26
|
-
return `\${param}`;
|
|
27
|
-
const paramName = params[paramIndex] || `param${paramIndex + 1}`;
|
|
28
|
-
paramIndex++;
|
|
29
|
-
return `\${${paramName}}`;
|
|
30
|
-
});
|
|
31
|
-
const example = {};
|
|
32
|
-
paramMatches.forEach((match, index) => {
|
|
33
|
-
example[params[index]] = match.replace(/[[\]]/g, '');
|
|
34
|
-
});
|
|
35
|
-
t.example = example;
|
|
36
|
-
}
|
|
37
|
-
t.suite_title = fileParts[fileParts.length - 1].replace(/\$/g, ' | ');
|
|
38
|
-
return t;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function namespaceToFileName(fileName) {
|
|
42
|
-
const fileParts = fileName.split('.');
|
|
43
|
-
fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
|
|
44
|
-
return `${fileParts.join(path_1.default.sep)}.kt`;
|
|
45
|
-
}
|
|
46
|
-
module.exports = KotlinAdapter;
|