@testomatio/reporter 2.9.1-beta.4-allure-step-status → 2.9.2
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 +2 -4
- package/lib/adapter/codecept.js +1 -0
- package/lib/adapter/playwright.js +19 -8
- package/lib/bin/cli.js +87 -29
- package/lib/junit-adapter/index.js +0 -4
- package/lib/pipe/debug.d.ts +6 -0
- package/lib/pipe/debug.js +11 -0
- package/lib/replay.js +21 -0
- package/lib/template/testomatio.hbs +77 -11
- package/lib/utils/pipe_utils.d.ts +0 -17
- package/lib/utils/pipe_utils.js +0 -45
- package/lib/utils/utils.js +0 -9
- package/lib/xmlReader.d.ts +1 -0
- package/lib/xmlReader.js +38 -2
- package/package.json +1 -1
- package/src/adapter/codecept.js +2 -0
- package/src/adapter/playwright.js +22 -9
- package/src/bin/cli.js +96 -36
- package/src/junit-adapter/index.js +0 -4
- package/src/pipe/debug.js +11 -0
- package/src/replay.js +21 -0
- package/src/template/testomatio.hbs +77 -11
- package/src/utils/pipe_utils.js +0 -49
- package/src/utils/utils.js +0 -5
- package/src/xmlReader.js +47 -2
- package/lib/allureReader.d.ts +0 -121
- package/lib/allureReader.js +0 -599
- package/lib/junit-adapter/kotlin.d.ts +0 -5
- package/lib/junit-adapter/kotlin.js +0 -46
- package/src/allureReader.js +0 -691
- package/src/junit-adapter/kotlin.js +0 -48
package/README.md
CHANGED
|
@@ -76,7 +76,6 @@ npx testomatio-reporter <command> [options]
|
|
|
76
76
|
| [TestCafe](./docs/frameworks.md#testcafe) | [Detox](./docs/frameworks.md#detox) | [Codeception](https://github.com/testomatio/php-reporter) |
|
|
77
77
|
| [Newman (Postman)](./docs/frameworks.md#newman) | [JUnit](./docs/junit.md#junit) | [NUnit](./docs/junit.md#nunit) |
|
|
78
78
|
| [PyTest](./docs/junit.md#pytest) | [PHPUnit](./docs/junit.md#phpunit) | [Protractor](./docs/frameworks.md#protractor) |
|
|
79
|
-
| [Allure](./docs/allure.md) | | |
|
|
80
79
|
|
|
81
80
|
or **any [other via JUnit](./docs/junit.md)** report....
|
|
82
81
|
|
|
@@ -138,10 +137,9 @@ Bring this reporter on CI and never lose test results again!
|
|
|
138
137
|
- [HTML report](./docs/pipes/html.md)
|
|
139
138
|
- [Markdown report](./docs/pipes/markdown.md)
|
|
140
139
|
- [Bitbucket](./docs/pipes/bitbucket.md)
|
|
141
|
-
- 📓 [JUnit Reports](./docs/junit.md)
|
|
142
|
-
- 🗄️ [Artifacts](./docs/artifacts.md)
|
|
143
|
-
- 🔬 [Allure Reports](./docs/allure.md)
|
|
144
140
|
- 🔗 [Linking Tests](./docs/linking-tests.md)
|
|
141
|
+
- 📓 [JUnit](./docs/junit.md)
|
|
142
|
+
- 🗄️ [Artifacts](./docs/artifacts.md)
|
|
145
143
|
- 🔂 [Workflows](./docs/workflows.md)
|
|
146
144
|
- 🖊️ [Logger](./docs/logger.md)
|
|
147
145
|
- 🪲 [Debug File Format](./docs/debug-file-format.md)
|
package/lib/adapter/codecept.js
CHANGED
|
@@ -237,6 +237,7 @@ async function uploadAttachments(client, attachments, messagePrefix, attachmentT
|
|
|
237
237
|
if (client.uploader.isEnabled) {
|
|
238
238
|
log_js_1.log.info(`Attachments: ${messagePrefix} ${attachments.length} ${attachmentType} ...`);
|
|
239
239
|
}
|
|
240
|
+
await Promise.all(client.pipes?.map(pipe => pipe.addArtifacts?.(attachments)) || []);
|
|
240
241
|
const promises = attachments.map(async (attachment) => {
|
|
241
242
|
const { rid, title, path, type } = attachment;
|
|
242
243
|
const file = { path, type, title };
|
|
@@ -51,13 +51,8 @@ class PlaywrightReporter {
|
|
|
51
51
|
const { title } = test;
|
|
52
52
|
const { error, duration } = result;
|
|
53
53
|
const pwAttachments = (result.attachments || []).filter(a => a.body || a.path);
|
|
54
|
-
const files = pwAttachments
|
|
55
|
-
|
|
56
|
-
path: this.#getArtifactPath(att),
|
|
57
|
-
title: att.name || title,
|
|
58
|
-
type: att.contentType,
|
|
59
|
-
}))
|
|
60
|
-
.filter(f => f.path);
|
|
54
|
+
const files = buildArtifactFiles(pwAttachments, attachment => this.#getArtifactPath(attachment), title);
|
|
55
|
+
const artifactsForUpload = processArtifactsForUpload(pwAttachments);
|
|
61
56
|
const suite_title = test.parent ? test.parent?.title : path_1.default.basename(test?.location?.file);
|
|
62
57
|
const rid = test.id || test.testId || (0, uuid_1.v4)();
|
|
63
58
|
/**
|
|
@@ -144,7 +139,7 @@ class PlaywrightReporter {
|
|
|
144
139
|
this.uploads.push({
|
|
145
140
|
rid: `${rid}-${project.name}`,
|
|
146
141
|
title: test.title,
|
|
147
|
-
files:
|
|
142
|
+
files: artifactsForUpload,
|
|
148
143
|
file: test.location?.file,
|
|
149
144
|
});
|
|
150
145
|
// remove empty uploads
|
|
@@ -210,6 +205,22 @@ function checkStatus(status) {
|
|
|
210
205
|
passed: constants_js_1.STATUS.PASSED,
|
|
211
206
|
}[status] || constants_js_1.STATUS.FAILED);
|
|
212
207
|
}
|
|
208
|
+
function buildArtifactFiles(attachments, getArtifactPath, title) {
|
|
209
|
+
return attachments
|
|
210
|
+
.filter(isScreenshotArtifact)
|
|
211
|
+
.map(attachment => ({
|
|
212
|
+
path: getArtifactPath(attachment),
|
|
213
|
+
title: attachment.name || title,
|
|
214
|
+
type: attachment.contentType,
|
|
215
|
+
}))
|
|
216
|
+
.filter(file => file.path);
|
|
217
|
+
}
|
|
218
|
+
function processArtifactsForUpload(attachments) {
|
|
219
|
+
return attachments.filter(attachment => !isScreenshotArtifact(attachment));
|
|
220
|
+
}
|
|
221
|
+
function isScreenshotArtifact(attachment) {
|
|
222
|
+
return attachment?.contentType === 'image/png' && attachment?.name === 'screenshot';
|
|
223
|
+
}
|
|
213
224
|
function appendStep(step, shift = 0) {
|
|
214
225
|
// nesting too deep, ignore those steps
|
|
215
226
|
if (shift >= 10)
|
package/lib/bin/cli.js
CHANGED
|
@@ -10,7 +10,6 @@ const glob_1 = require("glob");
|
|
|
10
10
|
const debug_1 = __importDefault(require("debug"));
|
|
11
11
|
const client_js_1 = __importDefault(require("../client.js"));
|
|
12
12
|
const xmlReader_js_1 = __importDefault(require("../xmlReader.js"));
|
|
13
|
-
const allureReader_js_1 = __importDefault(require("../allureReader.js"));
|
|
14
13
|
const constants_js_1 = require("../constants.js");
|
|
15
14
|
const utils_js_1 = require("../utils/utils.js");
|
|
16
15
|
const config_js_1 = require("../config.js");
|
|
@@ -21,6 +20,10 @@ const dotenv_1 = __importDefault(require("dotenv"));
|
|
|
21
20
|
const replay_js_1 = __importDefault(require("../replay.js"));
|
|
22
21
|
const log_js_1 = require("../utils/log.js");
|
|
23
22
|
const pipe_utils_js_1 = require("../utils/pipe_utils.js");
|
|
23
|
+
const fs_1 = __importDefault(require("fs"));
|
|
24
|
+
const path_1 = __importDefault(require("path"));
|
|
25
|
+
const gaxios_1 = require("gaxios");
|
|
26
|
+
const step_formatter_js_1 = require("../adapter/utils/step-formatter.js");
|
|
24
27
|
const debug = (0, debug_1.default)('@testomatio/reporter:cli');
|
|
25
28
|
const version = (0, utils_js_1.getPackageVersion)();
|
|
26
29
|
const program = new commander_1.Command();
|
|
@@ -319,39 +322,94 @@ program
|
|
|
319
322
|
if (timeoutTimer)
|
|
320
323
|
clearTimeout(timeoutTimer);
|
|
321
324
|
});
|
|
322
|
-
program
|
|
323
|
-
.command('allure')
|
|
324
|
-
.description('Parse Allure result files and upload to Testomat.io')
|
|
325
|
-
.argument('<pattern>', 'Allure result directory pattern')
|
|
326
|
-
.option('-d, --dir <dir>', 'Project directory')
|
|
327
|
-
.option('--timelimit <time>', 'default time limit in seconds to kill a stuck process')
|
|
328
|
-
.option('--with-package', 'Keep full package path in file names (default: strip package prefix)')
|
|
329
|
-
.action(async (pattern, opts) => {
|
|
330
|
-
const runReader = new allureReader_js_1.default({ withPackage: opts.withPackage });
|
|
331
|
-
let timeoutTimer;
|
|
332
|
-
if (opts.timelimit) {
|
|
333
|
-
timeoutTimer = setTimeout(() => {
|
|
334
|
-
console.log(`⚠️ Reached timeout of ${opts.timelimit}s. Exiting... (Exit code is 0 to not fail the pipeline)`);
|
|
335
|
-
process.exit(0);
|
|
336
|
-
}, parseInt(opts.timelimit, 10) * 1000);
|
|
337
|
-
}
|
|
338
|
-
try {
|
|
339
|
-
await runReader.parse(pattern);
|
|
340
|
-
await runReader.createRun();
|
|
341
|
-
await runReader.uploadData();
|
|
342
|
-
}
|
|
343
|
-
catch (err) {
|
|
344
|
-
console.log(constants_js_1.APP_PREFIX, 'Error uploading Allure results:', err);
|
|
345
|
-
}
|
|
346
|
-
if (timeoutTimer)
|
|
347
|
-
clearTimeout(timeoutTimer);
|
|
348
|
-
});
|
|
349
325
|
program
|
|
350
326
|
.command('upload-artifacts')
|
|
351
327
|
.description('Upload artifacts to Testomat.io')
|
|
328
|
+
.argument('[jsonl-file]', 'Path to JSONL debug file (optional)')
|
|
352
329
|
.option('--force', 'Re-upload artifacts even if they were uploaded before')
|
|
353
|
-
.action(async (opts) => {
|
|
330
|
+
.action(async (jsonlFile, opts) => {
|
|
354
331
|
const apiKey = config_js_1.config.TESTOMATIO;
|
|
332
|
+
// JSONL file mode: upload artifacts from debug file
|
|
333
|
+
if (jsonlFile) {
|
|
334
|
+
if (!fs_1.default.existsSync(jsonlFile)) {
|
|
335
|
+
log_js_1.log.error(`JSONL file not found: ${jsonlFile}`);
|
|
336
|
+
return process.exit(1);
|
|
337
|
+
}
|
|
338
|
+
const replay = new replay_js_1.default({ apiKey });
|
|
339
|
+
const { tests, runId } = replay.parseDebugFile(jsonlFile);
|
|
340
|
+
if (!runId) {
|
|
341
|
+
log_js_1.log.error('runId not found in JSONL file');
|
|
342
|
+
return process.exit(1);
|
|
343
|
+
}
|
|
344
|
+
log_js_1.log.info(`Processing ${tests.length} tests from ${jsonlFile}`);
|
|
345
|
+
const client = new client_js_1.default({
|
|
346
|
+
apiKey,
|
|
347
|
+
runId,
|
|
348
|
+
batchMode: constants_js_1.BATCH_MODE.DISABLED,
|
|
349
|
+
});
|
|
350
|
+
await client.createRun();
|
|
351
|
+
client.uploader.checkEnabled();
|
|
352
|
+
client.uploader.disableLogStorage();
|
|
353
|
+
const apiUrl = process.env.TESTOMATIO_URL || 'https://app.testomat.io';
|
|
354
|
+
const http = new gaxios_1.Gaxios();
|
|
355
|
+
let uploadedCount = 0;
|
|
356
|
+
let failedCount = 0;
|
|
357
|
+
for (const test of tests) {
|
|
358
|
+
const testId = test.test_id;
|
|
359
|
+
if (!testId)
|
|
360
|
+
continue;
|
|
361
|
+
const artifacts = [];
|
|
362
|
+
const collect = (items) => {
|
|
363
|
+
for (const item of items || []) {
|
|
364
|
+
const p = typeof item === 'object' ? item?.path : item;
|
|
365
|
+
if (p && fs_1.default.existsSync(p))
|
|
366
|
+
artifacts.push(p);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
collect(test.files);
|
|
370
|
+
const walkSteps = (steps) => {
|
|
371
|
+
for (const step of steps || []) {
|
|
372
|
+
collect(step.artifacts);
|
|
373
|
+
walkSteps(step.steps);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
walkSteps(test.steps);
|
|
377
|
+
if (artifacts.length === 0)
|
|
378
|
+
continue;
|
|
379
|
+
const urls = [];
|
|
380
|
+
for (const artifact of artifacts) {
|
|
381
|
+
try {
|
|
382
|
+
const s3Id = test.rid || testId.replace('@', '');
|
|
383
|
+
const filename = (0, step_formatter_js_1.generateShortFilename)(artifact);
|
|
384
|
+
const result = await client.uploader.uploadFileByPath(artifact, [runId, s3Id, filename]);
|
|
385
|
+
if (result)
|
|
386
|
+
urls.push(typeof result === 'string' ? result : result.link);
|
|
387
|
+
}
|
|
388
|
+
catch (e) {
|
|
389
|
+
debug(`Failed to upload ${artifact}:`, e.message);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (urls.length === 0)
|
|
393
|
+
continue;
|
|
394
|
+
try {
|
|
395
|
+
await http.request({
|
|
396
|
+
method: 'POST',
|
|
397
|
+
url: `${apiUrl}/api/reporter/${runId}/testrun?api_key=${apiKey}`,
|
|
398
|
+
data: { test_id: testId, artifacts: urls },
|
|
399
|
+
});
|
|
400
|
+
uploadedCount++;
|
|
401
|
+
}
|
|
402
|
+
catch (e) {
|
|
403
|
+
log_js_1.log.error(`Failed ${testId}: ${e.message}`);
|
|
404
|
+
failedCount++;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
log_js_1.log.info(`🗄️ ${uploadedCount} tests with artifacts uploaded`);
|
|
408
|
+
if (failedCount > 0) {
|
|
409
|
+
log_js_1.log.warn(`⚠️ ${failedCount} tests failed to upload artifacts`);
|
|
410
|
+
}
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
355
413
|
process.env.TESTOMATIO_DISABLE_ARTIFACTS = '';
|
|
356
414
|
const runId = process.env.TESTOMATIO_RUN || process.env.runId || (0, utils_js_2.readLatestRunId)();
|
|
357
415
|
if (!runId) {
|
|
@@ -9,7 +9,6 @@ const java_js_1 = __importDefault(require("./java.js"));
|
|
|
9
9
|
const python_js_1 = __importDefault(require("./python.js"));
|
|
10
10
|
const ruby_js_1 = __importDefault(require("./ruby.js"));
|
|
11
11
|
const csharp_js_1 = __importDefault(require("./csharp.js"));
|
|
12
|
-
const kotlin_js_1 = __importDefault(require("./kotlin.js"));
|
|
13
12
|
function AdapterFactory(lang, opts) {
|
|
14
13
|
if (lang === 'java') {
|
|
15
14
|
return new java_js_1.default(opts);
|
|
@@ -26,9 +25,6 @@ function AdapterFactory(lang, opts) {
|
|
|
26
25
|
if (lang === 'c#' || lang === 'csharp') {
|
|
27
26
|
return new csharp_js_1.default(opts);
|
|
28
27
|
}
|
|
29
|
-
if (lang === 'kotlin') {
|
|
30
|
-
return new kotlin_js_1.default(opts);
|
|
31
|
-
}
|
|
32
28
|
return new adapter_js_1.default(opts);
|
|
33
29
|
}
|
|
34
30
|
module.exports = AdapterFactory;
|
package/lib/pipe/debug.d.ts
CHANGED
|
@@ -22,6 +22,12 @@ export class DebugPipe {
|
|
|
22
22
|
createRun(params?: {}): Promise<void>;
|
|
23
23
|
addTest(data: any): Promise<void>;
|
|
24
24
|
finishRun(params: any): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Logs artifacts data to the debug file.
|
|
27
|
+
* Used for trace.zip, video files and other artifacts uploaded after tests finish.
|
|
28
|
+
* @param {Array} artifacts - Array of artifacts with { rid, title, path, type }
|
|
29
|
+
*/
|
|
30
|
+
addArtifacts(artifacts: any[]): void;
|
|
25
31
|
sync(): Promise<void>;
|
|
26
32
|
/**
|
|
27
33
|
* Writes any buffered tests to the debug file as a single batch.
|
package/lib/pipe/debug.js
CHANGED
|
@@ -109,6 +109,17 @@ class DebugPipe {
|
|
|
109
109
|
log_js_1.log.info(`🪲 Debug file: ${this.rootPath}`);
|
|
110
110
|
log_js_1.log.info(`History: ${this.historyDir}`);
|
|
111
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Logs artifacts data to the debug file.
|
|
114
|
+
* Used for trace.zip, video files and other artifacts uploaded after tests finish.
|
|
115
|
+
* @param {Array} artifacts - Array of artifacts with { rid, title, path, type }
|
|
116
|
+
*/
|
|
117
|
+
addArtifacts(artifacts) {
|
|
118
|
+
if (!this.isEnabled || !artifacts?.length)
|
|
119
|
+
return;
|
|
120
|
+
const logData = { action: 'addArtifacts', artifacts, runId: this.store.runId };
|
|
121
|
+
this.logToFile(logData);
|
|
122
|
+
}
|
|
112
123
|
async sync() {
|
|
113
124
|
this.flushBufferedTests();
|
|
114
125
|
}
|
package/lib/replay.js
CHANGED
|
@@ -49,6 +49,7 @@ class Replay {
|
|
|
49
49
|
const testsWithoutRid = []; // For tests without rid (backward compatibility)
|
|
50
50
|
const envVars = {};
|
|
51
51
|
let runId = null;
|
|
52
|
+
const artifactsToAdd = []; // Store artifacts to add after all tests are loaded
|
|
52
53
|
// Parse debug file line by line
|
|
53
54
|
for (const [lineIndex, line] of lines.entries()) {
|
|
54
55
|
try {
|
|
@@ -125,6 +126,12 @@ class Replay {
|
|
|
125
126
|
testsWithoutRid.push({ ...test });
|
|
126
127
|
}
|
|
127
128
|
}
|
|
129
|
+
else if (logEntry.action === 'addArtifacts' && logEntry.artifacts) {
|
|
130
|
+
if (logEntry.runId && !runId) {
|
|
131
|
+
runId = logEntry.runId;
|
|
132
|
+
}
|
|
133
|
+
artifactsToAdd.push(...logEntry.artifacts);
|
|
134
|
+
}
|
|
128
135
|
else if (logEntry.action === 'finishRun') {
|
|
129
136
|
finishParams = logEntry.params || {};
|
|
130
137
|
if (logEntry.runId && !runId) {
|
|
@@ -143,6 +150,20 @@ class Replay {
|
|
|
143
150
|
if (parseErrors > 3) {
|
|
144
151
|
this.onError(`${parseErrors - 3} more parse errors occurred`);
|
|
145
152
|
}
|
|
153
|
+
for (const artifact of artifactsToAdd) {
|
|
154
|
+
if (artifact.rid) {
|
|
155
|
+
const ridToFind = artifact.rid;
|
|
156
|
+
const fullRid = runId ? `${runId}-${ridToFind}` : ridToFind;
|
|
157
|
+
const test = testsMap.get(fullRid) || testsMap.get(ridToFind);
|
|
158
|
+
if (test && artifact.path) {
|
|
159
|
+
if (!test.files)
|
|
160
|
+
test.files = [];
|
|
161
|
+
if (!test.files.includes(artifact.path)) {
|
|
162
|
+
test.files.push(artifact.path);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
146
167
|
// Combine tests with rid and tests without rid
|
|
147
168
|
const allTests = [...Array.from(testsMap.values()), ...testsWithoutRid];
|
|
148
169
|
return {
|
|
@@ -681,8 +681,9 @@
|
|
|
681
681
|
|
|
682
682
|
.test-group-header {
|
|
683
683
|
padding: 20px;
|
|
684
|
-
background:
|
|
685
|
-
color:
|
|
684
|
+
background: var(--gray-50);
|
|
685
|
+
color: var(--gray-800);
|
|
686
|
+
border-left: 4px solid var(--primary-color);
|
|
686
687
|
cursor: pointer;
|
|
687
688
|
display: flex;
|
|
688
689
|
justify-content: space-between;
|
|
@@ -691,7 +692,37 @@
|
|
|
691
692
|
}
|
|
692
693
|
|
|
693
694
|
.test-group-header:hover {
|
|
694
|
-
|
|
695
|
+
background: var(--gray-100);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
.test-group-header.has-failures {
|
|
699
|
+
background: #fef2f2;
|
|
700
|
+
color: var(--gray-900);
|
|
701
|
+
border-left-color: var(--danger-color);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
.test-group-header.has-failures:hover {
|
|
705
|
+
background: #fee2e2;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.test-group-header.has-skips {
|
|
709
|
+
background: #fffbeb;
|
|
710
|
+
color: var(--gray-900);
|
|
711
|
+
border-left-color: var(--warning-color);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
.test-group-header.has-skips:hover {
|
|
715
|
+
background: #fef3c7;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.test-group-header.all-passed {
|
|
719
|
+
background: #ecfdf5;
|
|
720
|
+
color: var(--gray-900);
|
|
721
|
+
border-left-color: var(--success-color);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
.test-group-header.all-passed:hover {
|
|
725
|
+
background: #d1fae5;
|
|
695
726
|
}
|
|
696
727
|
|
|
697
728
|
.test-group-title {
|
|
@@ -707,28 +738,56 @@
|
|
|
707
738
|
}
|
|
708
739
|
|
|
709
740
|
.test-group-count {
|
|
710
|
-
background:
|
|
741
|
+
background: white;
|
|
742
|
+
color: var(--gray-600);
|
|
711
743
|
padding: 6px 16px;
|
|
712
744
|
border-radius: 20px;
|
|
713
745
|
font-size: 14px;
|
|
714
746
|
font-weight: 600;
|
|
747
|
+
border: 1px solid var(--gray-200);
|
|
715
748
|
}
|
|
716
749
|
|
|
717
750
|
.test-group-stats {
|
|
718
751
|
display: flex;
|
|
719
|
-
gap:
|
|
752
|
+
gap: 8px;
|
|
720
753
|
font-size: 14px;
|
|
721
754
|
margin-right: 10px;
|
|
755
|
+
flex-wrap: wrap;
|
|
756
|
+
justify-content: flex-end;
|
|
722
757
|
}
|
|
723
758
|
|
|
724
759
|
.test-group-stat {
|
|
725
760
|
display: flex;
|
|
726
761
|
align-items: center;
|
|
727
762
|
gap: 6px;
|
|
763
|
+
padding: 6px 10px;
|
|
764
|
+
border-radius: 999px;
|
|
765
|
+
font-weight: 700;
|
|
766
|
+
background: white;
|
|
767
|
+
border: 1px solid currentColor;
|
|
728
768
|
}
|
|
729
769
|
|
|
730
|
-
.test-group-
|
|
770
|
+
.test-group-stat.passed {
|
|
771
|
+
color: var(--success-color);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
.test-group-stat.failed {
|
|
731
775
|
color: white;
|
|
776
|
+
background: var(--danger-color);
|
|
777
|
+
border-color: var(--danger-color);
|
|
778
|
+
box-shadow: 0 1px 3px rgba(239, 68, 68, 0.35);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
.test-group-stat.skipped {
|
|
782
|
+
color: var(--warning-color);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.test-group-stat.todo {
|
|
786
|
+
color: #8b5cf6;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
.test-group-expand {
|
|
790
|
+
color: var(--gray-500);
|
|
732
791
|
transition: var(--transition);
|
|
733
792
|
font-size: 18px;
|
|
734
793
|
}
|
|
@@ -3366,11 +3425,18 @@
|
|
|
3366
3425
|
const failedCount = group.tests.filter(t => t.status.toLowerCase() === 'failed').length;
|
|
3367
3426
|
const skippedCount = group.tests.filter(t => t.status.toLowerCase() === 'skipped').length;
|
|
3368
3427
|
const todoCount = group.tests.filter(t => t.status.toLowerCase() === 'todo').length;
|
|
3428
|
+
const groupStateClass = failedCount > 0
|
|
3429
|
+
? 'has-failures'
|
|
3430
|
+
: skippedCount > 0 || todoCount > 0
|
|
3431
|
+
? 'has-skips'
|
|
3432
|
+
: passedCount > 0
|
|
3433
|
+
? 'all-passed'
|
|
3434
|
+
: '';
|
|
3369
3435
|
|
|
3370
3436
|
const groupIcon = group.type === 'suite' ? 'layer-group' : 'file-code';
|
|
3371
3437
|
|
|
3372
3438
|
const header = document.createElement('div');
|
|
3373
|
-
header.className = 'test-group-header';
|
|
3439
|
+
header.className = ['test-group-header', groupStateClass].filter(Boolean).join(' ');
|
|
3374
3440
|
header.innerHTML = `
|
|
3375
3441
|
<div class='test-group-title'>
|
|
3376
3442
|
<i class='fas fa-${groupIcon}'></i>
|
|
@@ -3378,10 +3444,10 @@
|
|
|
3378
3444
|
<div class='test-group-count'>${group.tests.length} tests</div>
|
|
3379
3445
|
</div>
|
|
3380
3446
|
<div class='test-group-stats'>
|
|
3381
|
-
${passedCount > 0 ? `<div class='test-group-stat
|
|
3382
|
-
${failedCount > 0 ? `<div class='test-group-stat
|
|
3383
|
-
${skippedCount > 0 ? `<div class='test-group-stat
|
|
3384
|
-
${todoCount > 0 ? `<div class='test-group-stat
|
|
3447
|
+
${passedCount > 0 ? `<div class='test-group-stat passed'><i class='fas fa-check-circle'></i> ${passedCount}</div>` : ''}
|
|
3448
|
+
${failedCount > 0 ? `<div class='test-group-stat failed'><i class='fas fa-times-circle'></i> ${failedCount}</div>` : ''}
|
|
3449
|
+
${skippedCount > 0 ? `<div class='test-group-stat skipped'><i class='fas fa-forward'></i> ${skippedCount}</div>` : ''}
|
|
3450
|
+
${todoCount > 0 ? `<div class='test-group-stat todo'><i class='fas fa-clock'></i> ${todoCount}</div>` : ''}
|
|
3385
3451
|
</div>
|
|
3386
3452
|
<i class='fas fa-chevron-down test-group-expand'></i>
|
|
3387
3453
|
`;
|
|
@@ -64,20 +64,3 @@ export function parsePipeOptions(optionsStr?: string): any;
|
|
|
64
64
|
* @returns {string} Empty string if no ids; otherwise the formatted output.
|
|
65
65
|
*/
|
|
66
66
|
export function formatFilterListIds(ids: string[], format: "grep" | "json" | "newline" | "ids"): string;
|
|
67
|
-
/**
|
|
68
|
-
* Calculate the approximate size of data in bytes (JSON stringified, UTF-8 encoded length).
|
|
69
|
-
* @param {Object} data - Data to measure
|
|
70
|
-
* @returns {number} Size in bytes
|
|
71
|
-
*/
|
|
72
|
-
export function getObjectSize(data: any): number;
|
|
73
|
-
/**
|
|
74
|
-
* Split a tests array into chunks bounded by serialized size.
|
|
75
|
-
* Used by the XML and Allure readers so both upload tests with identical batching:
|
|
76
|
-
* each chunk becomes a single batch request (manual batch mode), which keeps requests
|
|
77
|
-
* under the size limit and guarantees every test is sent exactly once.
|
|
78
|
-
*
|
|
79
|
-
* @param {Array} tests - Array of tests to split
|
|
80
|
-
* @param {number} [maxSizeBytes=1048576] - Maximum serialized size per chunk (default 1MB)
|
|
81
|
-
* @returns {Array<Array>} Array of test chunks
|
|
82
|
-
*/
|
|
83
|
-
export function splitTestsIntoChunks(tests: any[], maxSizeBytes?: number): Array<any[]>;
|
package/lib/utils/pipe_utils.js
CHANGED
|
@@ -8,8 +8,6 @@ exports.statusEmoji = statusEmoji;
|
|
|
8
8
|
exports.fullName = fullName;
|
|
9
9
|
exports.parsePipeOptions = parsePipeOptions;
|
|
10
10
|
exports.formatFilterListIds = formatFilterListIds;
|
|
11
|
-
exports.getObjectSize = getObjectSize;
|
|
12
|
-
exports.splitTestsIntoChunks = splitTestsIntoChunks;
|
|
13
11
|
const log_js_1 = require("./log.js");
|
|
14
12
|
/**
|
|
15
13
|
* Set S3 credentials from the provided artifacts object.
|
|
@@ -164,45 +162,6 @@ function parsePipeOptions(optionsStr) {
|
|
|
164
162
|
}
|
|
165
163
|
return options;
|
|
166
164
|
}
|
|
167
|
-
/**
|
|
168
|
-
* Calculate the approximate size of data in bytes (JSON stringified, UTF-8 encoded length).
|
|
169
|
-
* @param {Object} data - Data to measure
|
|
170
|
-
* @returns {number} Size in bytes
|
|
171
|
-
*/
|
|
172
|
-
function getObjectSize(data) {
|
|
173
|
-
const body = JSON.stringify(data);
|
|
174
|
-
return new TextEncoder().encode(body).length;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Split a tests array into chunks bounded by serialized size.
|
|
178
|
-
* Used by the XML and Allure readers so both upload tests with identical batching:
|
|
179
|
-
* each chunk becomes a single batch request (manual batch mode), which keeps requests
|
|
180
|
-
* under the size limit and guarantees every test is sent exactly once.
|
|
181
|
-
*
|
|
182
|
-
* @param {Array} tests - Array of tests to split
|
|
183
|
-
* @param {number} [maxSizeBytes=1048576] - Maximum serialized size per chunk (default 1MB)
|
|
184
|
-
* @returns {Array<Array>} Array of test chunks
|
|
185
|
-
*/
|
|
186
|
-
function splitTestsIntoChunks(tests, maxSizeBytes = 1 * 1024 * 1024) {
|
|
187
|
-
const chunks = [];
|
|
188
|
-
let currentChunk = [];
|
|
189
|
-
let currentChunkSize = 0;
|
|
190
|
-
for (const test of tests) {
|
|
191
|
-
const testSize = getObjectSize(test);
|
|
192
|
-
const wouldExceedSize = currentChunkSize + testSize > maxSizeBytes;
|
|
193
|
-
if (wouldExceedSize && currentChunk.length > 0) {
|
|
194
|
-
chunks.push(currentChunk);
|
|
195
|
-
currentChunk = [];
|
|
196
|
-
currentChunkSize = 0;
|
|
197
|
-
}
|
|
198
|
-
currentChunk.push(test);
|
|
199
|
-
currentChunkSize += testSize;
|
|
200
|
-
}
|
|
201
|
-
if (currentChunk.length > 0) {
|
|
202
|
-
chunks.push(currentChunk);
|
|
203
|
-
}
|
|
204
|
-
return chunks;
|
|
205
|
-
}
|
|
206
165
|
/**
|
|
207
166
|
* Format a list of test IDs for `--filter-list` machine-readable output.
|
|
208
167
|
* Used when the CLI `--format` option is passed,
|
|
@@ -239,7 +198,3 @@ module.exports.fullName = fullName;
|
|
|
239
198
|
module.exports.parsePipeOptions = parsePipeOptions;
|
|
240
199
|
|
|
241
200
|
module.exports.formatFilterListIds = formatFilterListIds;
|
|
242
|
-
|
|
243
|
-
module.exports.getObjectSize = getObjectSize;
|
|
244
|
-
|
|
245
|
-
module.exports.splitTestsIntoChunks = splitTestsIntoChunks;
|
package/lib/utils/utils.js
CHANGED
|
@@ -324,15 +324,6 @@ const fetchSourceCode = (contents, opts = {}) => {
|
|
|
324
324
|
if (lineIndex === -1)
|
|
325
325
|
lineIndex = lines.findIndex(l => l.includes(`${title}(`));
|
|
326
326
|
}
|
|
327
|
-
else if (opts.lang === 'kotlin') {
|
|
328
|
-
lineIndex = lines.findIndex(l => l.includes(`fun test${title}`));
|
|
329
|
-
if (lineIndex === -1)
|
|
330
|
-
lineIndex = lines.findIndex(l => l.includes(`@DisplayName("${title}`));
|
|
331
|
-
if (lineIndex === -1)
|
|
332
|
-
lineIndex = lines.findIndex(l => l.includes(`fun ${title}`));
|
|
333
|
-
if (lineIndex === -1)
|
|
334
|
-
lineIndex = lines.findIndex(l => l.includes(`${title}(`));
|
|
335
|
-
}
|
|
336
327
|
else if (opts.lang === 'csharp') {
|
|
337
328
|
// Find the method declaration line
|
|
338
329
|
let methodLineIndex = lines.findIndex(l => l.includes(`public void ${title}(`));
|
package/lib/xmlReader.d.ts
CHANGED
package/lib/xmlReader.js
CHANGED
|
@@ -14,7 +14,6 @@ const url_1 = require("url");
|
|
|
14
14
|
const nunit_parser_js_1 = require("./junit-adapter/nunit-parser.js");
|
|
15
15
|
const utils_js_1 = require("./utils/utils.js");
|
|
16
16
|
const index_js_1 = require("./pipe/index.js");
|
|
17
|
-
const pipe_utils_js_1 = require("./utils/pipe_utils.js");
|
|
18
17
|
const index_js_2 = __importDefault(require("./junit-adapter/index.js"));
|
|
19
18
|
const config_js_1 = require("./config.js");
|
|
20
19
|
const uploader_js_1 = require("./uploader.js");
|
|
@@ -475,6 +474,43 @@ class XmlReader {
|
|
|
475
474
|
this.uploader.checkEnabled();
|
|
476
475
|
return run;
|
|
477
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Calculate the approximate size of data in bytes (JSON stringified length)
|
|
479
|
+
* @param {Object} data - Data to measure
|
|
480
|
+
* @returns {number} Size in bytes
|
|
481
|
+
*/
|
|
482
|
+
#getObjectSize(data) {
|
|
483
|
+
const body = JSON.stringify(data);
|
|
484
|
+
return new TextEncoder().encode(body).length;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Split tests array into chunks based on data size
|
|
488
|
+
* @param {Array} tests - Array of tests to split
|
|
489
|
+
* @returns {Array<Array>} Array of test chunks
|
|
490
|
+
*/
|
|
491
|
+
#splitTestsIntoChunks(tests) {
|
|
492
|
+
const maxSizeBytes = 1 * 1024 * 1024;
|
|
493
|
+
const chunks = [];
|
|
494
|
+
let currentChunk = [];
|
|
495
|
+
let currentChunkSize = 0;
|
|
496
|
+
for (const test of tests) {
|
|
497
|
+
const testSize = this.#getObjectSize(test);
|
|
498
|
+
const wouldExceedSize = currentChunkSize + testSize > maxSizeBytes;
|
|
499
|
+
if (wouldExceedSize) {
|
|
500
|
+
if (currentChunk.length > 0) {
|
|
501
|
+
chunks.push(currentChunk);
|
|
502
|
+
}
|
|
503
|
+
currentChunk = [];
|
|
504
|
+
currentChunkSize = 0;
|
|
505
|
+
}
|
|
506
|
+
currentChunk.push(test);
|
|
507
|
+
currentChunkSize += testSize;
|
|
508
|
+
}
|
|
509
|
+
if (currentChunk.length > 0) {
|
|
510
|
+
chunks.push(currentChunk);
|
|
511
|
+
}
|
|
512
|
+
return chunks;
|
|
513
|
+
}
|
|
478
514
|
async uploadData() {
|
|
479
515
|
await this.uploadArtifacts();
|
|
480
516
|
this.calculateStats();
|
|
@@ -495,7 +531,7 @@ class XmlReader {
|
|
|
495
531
|
};
|
|
496
532
|
return Promise.all(this.pipes.map(p => p.finishRun(finishData)));
|
|
497
533
|
}
|
|
498
|
-
const testChunks =
|
|
534
|
+
const testChunks = this.#splitTestsIntoChunks(this.tests);
|
|
499
535
|
const totalChunks = testChunks.length;
|
|
500
536
|
const totalTests = this.tests.length;
|
|
501
537
|
debug(`Split ${totalTests} tests into ${totalChunks} chunks (max 1MB per chunk)`);
|
package/package.json
CHANGED
package/src/adapter/codecept.js
CHANGED
|
@@ -278,6 +278,8 @@ async function uploadAttachments(client, attachments, messagePrefix, attachmentT
|
|
|
278
278
|
log.info(`Attachments: ${messagePrefix} ${attachments.length} ${attachmentType} ...`);
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
await Promise.all(client.pipes?.map(pipe => pipe.addArtifacts?.(attachments)) || []);
|
|
282
|
+
|
|
281
283
|
const promises = attachments.map(async attachment => {
|
|
282
284
|
const { rid, title, path, type } = attachment;
|
|
283
285
|
const file = { path, type, title };
|