@testomatio/reporter 2.0.1-beta-2-ignore-xml → 2.0.1-beta.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/lib/adapter/codecept.js +0 -2
- package/lib/adapter/cypress-plugin/index.js +0 -2
- package/lib/adapter/mocha.js +0 -1
- package/lib/adapter/nightwatch.d.ts +4 -0
- package/lib/adapter/nightwatch.js +80 -0
- package/lib/adapter/webdriver.d.ts +1 -1
- package/lib/adapter/webdriver.js +18 -8
- package/lib/bin/cli.js +73 -8
- package/lib/bin/reportXml.js +4 -2
- package/lib/bin/startTest.js +3 -2
- package/lib/bin/uploadArtifacts.js +5 -4
- package/lib/client.js +18 -9
- package/lib/config.js +2 -2
- package/lib/data-storage.d.ts +1 -1
- package/lib/data-storage.js +17 -7
- package/lib/junit-adapter/csharp.d.ts +1 -0
- package/lib/junit-adapter/csharp.js +11 -1
- package/lib/pipe/bitbucket.d.ts +2 -0
- package/lib/pipe/bitbucket.js +38 -26
- package/lib/pipe/debug.js +17 -3
- package/lib/pipe/github.d.ts +2 -2
- package/lib/pipe/github.js +35 -3
- package/lib/pipe/gitlab.d.ts +2 -0
- package/lib/pipe/gitlab.js +27 -9
- package/lib/pipe/html.d.ts +1 -0
- package/lib/pipe/html.js +1 -3
- package/lib/pipe/index.js +17 -7
- package/lib/pipe/testomatio.d.ts +3 -2
- package/lib/pipe/testomatio.js +85 -75
- package/lib/replay.d.ts +31 -0
- package/lib/replay.js +237 -0
- package/lib/reporter.d.ts +12 -12
- package/lib/services/artifacts.d.ts +1 -1
- package/lib/services/key-values.d.ts +1 -1
- package/lib/services/logger.d.ts +1 -1
- package/lib/services/logger.js +1 -2
- package/lib/template/testomatio.hbs +443 -68
- package/lib/uploader.js +10 -6
- package/lib/utils/utils.d.ts +3 -1
- package/lib/utils/utils.js +54 -21
- package/lib/xmlReader.js +54 -19
- package/package.json +8 -9
- package/src/adapter/codecept.js +0 -2
- package/src/adapter/cypress-plugin/index.js +0 -2
- package/src/adapter/mocha.js +0 -1
- package/src/adapter/nightwatch.js +88 -0
- package/src/adapter/webdriver.js +2 -2
- package/src/bin/cli.js +70 -2
- package/src/bin/reportXml.js +4 -1
- package/src/bin/startTest.js +2 -1
- package/src/bin/uploadArtifacts.js +2 -1
- package/src/client.js +1 -2
- package/src/config.js +2 -2
- package/src/junit-adapter/csharp.js +13 -1
- package/src/pipe/bitbucket.js +22 -24
- package/src/pipe/debug.js +18 -3
- package/src/pipe/github.js +1 -2
- package/src/pipe/gitlab.js +27 -9
- package/src/pipe/html.js +3 -4
- package/src/pipe/testomatio.js +106 -105
- package/src/replay.js +245 -0
- package/src/services/logger.js +1 -2
- package/src/template/testomatio.hbs +443 -68
- package/src/uploader.js +11 -6
- package/src/utils/utils.js +31 -12
- package/src/xmlReader.js +69 -17
package/lib/utils/utils.js
CHANGED
|
@@ -15,18 +15,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.testRunnerHelper = exports.specificTestInfo = exports.parseSuite = exports.isValidUrl = exports.humanize = exports.getTestomatIdFromTestTitle = exports.getCurrentDateTime = exports.foundedTestLog = exports.fileSystem = exports.fetchFilesFromStackTrace = exports.fetchIdFromOutput = exports.fetchIdFromCode = exports.fetchSourceCodeFromStackTrace = exports.fetchSourceCode = exports.isSameTest = exports.ansiRegExp = void 0;
|
|
39
|
+
exports.testRunnerHelper = exports.specificTestInfo = exports.parseSuite = exports.isValidUrl = exports.humanize = exports.getTestomatIdFromTestTitle = exports.getCurrentDateTime = exports.foundedTestLog = exports.fileSystem = exports.fetchFilesFromStackTrace = exports.fetchIdFromOutput = exports.fetchIdFromCode = exports.fetchSourceCodeFromStackTrace = exports.fetchSourceCode = exports.isSameTest = exports.ansiRegExp = exports.TEST_ID_REGEX = void 0;
|
|
40
|
+
exports.getPackageVersion = getPackageVersion;
|
|
30
41
|
exports.formatStep = formatStep;
|
|
31
42
|
exports.readLatestRunId = readLatestRunId;
|
|
32
43
|
exports.removeColorCodes = removeColorCodes;
|
|
@@ -38,7 +49,12 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
38
49
|
const is_valid_path_1 = __importDefault(require("is-valid-path"));
|
|
39
50
|
const debug_1 = __importDefault(require("debug"));
|
|
40
51
|
const os_1 = __importDefault(require("os"));
|
|
52
|
+
const url_2 = require("url");
|
|
41
53
|
const debug = (0, debug_1.default)('@testomatio/reporter:util');
|
|
54
|
+
// Use __dirname directly since we're compiling to CommonJS
|
|
55
|
+
// prettier-ignore
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
// eslint-disable-next-line max-len
|
|
42
58
|
/**
|
|
43
59
|
* @param {String} testTitle - Test title
|
|
44
60
|
*
|
|
@@ -77,7 +93,6 @@ const ansiRegExp = () => {
|
|
|
77
93
|
exports.ansiRegExp = ansiRegExp;
|
|
78
94
|
const isValidUrl = s => {
|
|
79
95
|
try {
|
|
80
|
-
// eslint-disable-next-line no-new
|
|
81
96
|
new url_1.URL(s);
|
|
82
97
|
return true;
|
|
83
98
|
}
|
|
@@ -86,13 +101,23 @@ const isValidUrl = s => {
|
|
|
86
101
|
}
|
|
87
102
|
};
|
|
88
103
|
exports.isValidUrl = isValidUrl;
|
|
89
|
-
const fileMatchRegex = /file:(
|
|
90
|
-
const fetchFilesFromStackTrace = (stack = '') => {
|
|
104
|
+
const fileMatchRegex = /file:(\/+(?:[A-Za-z]:[\\/]|\/)?[^\s]*?\.(png|avi|webm|jpg|html|txt))/gi;
|
|
105
|
+
const fetchFilesFromStackTrace = (stack = '', checkExists = true) => {
|
|
91
106
|
const files = Array.from(stack.matchAll(fileMatchRegex))
|
|
92
107
|
.map(f => f[1].trim())
|
|
93
|
-
.map(f =>
|
|
108
|
+
.map(f => f.replace(/^\/+/, '/').replace(/^\/([A-Za-z]:)/, '$1')) // Remove extra slashes, handle Windows paths
|
|
109
|
+
.map(f => {
|
|
110
|
+
// Convert Windows paths to Linux paths for testing purposes
|
|
111
|
+
if (f.match(/^[A-Za-z]:[\\\/]/)) {
|
|
112
|
+
// Convert Windows path to Linux equivalent for test scenarios
|
|
113
|
+
return f.replace(/^[A-Za-z]:[\\\/]/, '/').replace(/\\/g, '/');
|
|
114
|
+
}
|
|
115
|
+
return f;
|
|
116
|
+
});
|
|
94
117
|
debug('Found files in stack trace: ', files);
|
|
95
118
|
return files.filter(f => {
|
|
119
|
+
if (!checkExists)
|
|
120
|
+
return true;
|
|
96
121
|
const isFile = fs_1.default.existsSync(f);
|
|
97
122
|
if (!isFile)
|
|
98
123
|
debug('File %s could not be found and uploaded as artifact', f);
|
|
@@ -131,7 +156,7 @@ const fetchSourceCodeFromStackTrace = (stack = '') => {
|
|
|
131
156
|
.join('\n');
|
|
132
157
|
};
|
|
133
158
|
exports.fetchSourceCodeFromStackTrace = fetchSourceCodeFromStackTrace;
|
|
134
|
-
|
|
159
|
+
exports.TEST_ID_REGEX = /@T([\w\d]{8})/;
|
|
135
160
|
const fetchIdFromCode = (code, opts = {}) => {
|
|
136
161
|
const comments = code
|
|
137
162
|
.split('\n')
|
|
@@ -145,15 +170,12 @@ const fetchIdFromCode = (code, opts = {}) => {
|
|
|
145
170
|
return l.startsWith('// ');
|
|
146
171
|
}
|
|
147
172
|
});
|
|
148
|
-
return comments.find(c => c.match(TEST_ID_REGEX))?.match(TEST_ID_REGEX)?.[1];
|
|
173
|
+
return comments.find(c => c.match(exports.TEST_ID_REGEX))?.match(exports.TEST_ID_REGEX)?.[1];
|
|
149
174
|
};
|
|
150
175
|
exports.fetchIdFromCode = fetchIdFromCode;
|
|
151
176
|
const fetchIdFromOutput = output => {
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
.map(l => l.trim())
|
|
155
|
-
.filter(l => l.startsWith('tid://'));
|
|
156
|
-
return lines.find(c => c.match(TEST_ID_REGEX))?.match(TEST_ID_REGEX)?.[1];
|
|
177
|
+
const TID_FULL_PATTERN = new RegExp(`tid:\\/\\/.*?(${exports.TEST_ID_REGEX.source})`);
|
|
178
|
+
return output.match(TID_FULL_PATTERN)?.[2];
|
|
157
179
|
};
|
|
158
180
|
exports.fetchIdFromOutput = fetchIdFromOutput;
|
|
159
181
|
const fetchSourceCode = (contents, opts = {}) => {
|
|
@@ -177,6 +199,12 @@ const fetchSourceCode = (contents, opts = {}) => {
|
|
|
177
199
|
if (lineIndex === -1)
|
|
178
200
|
lineIndex = lines.findIndex(l => l.includes(`${title}(`));
|
|
179
201
|
}
|
|
202
|
+
else if (opts.lang === 'csharp') {
|
|
203
|
+
if (lineIndex === -1)
|
|
204
|
+
lineIndex = lines.findIndex(l => l.includes(`public void ${title}`));
|
|
205
|
+
if (lineIndex === -1)
|
|
206
|
+
lineIndex = lines.findIndex(l => l.includes(`${title}(`));
|
|
207
|
+
}
|
|
180
208
|
else {
|
|
181
209
|
lineIndex = lines.findIndex(l => l.includes(title));
|
|
182
210
|
}
|
|
@@ -324,7 +352,6 @@ const decamelize = text => {
|
|
|
324
352
|
* @returns
|
|
325
353
|
*/
|
|
326
354
|
function removeColorCodes(input) {
|
|
327
|
-
// eslint-disable-next-line no-control-regex
|
|
328
355
|
return input.replace(/\x1b\[[0-9;]*m/g, '');
|
|
329
356
|
}
|
|
330
357
|
const testRunnerHelper = {
|
|
@@ -337,7 +364,6 @@ const testRunnerHelper = {
|
|
|
337
364
|
try {
|
|
338
365
|
// TODO: expect?.getState()?.testPath + ' ' + expect?.getState()?.currentTestName
|
|
339
366
|
// @ts-expect-error "expect" could only be defined inside Jest environement (forbidden to import it outside)
|
|
340
|
-
// eslint-disable-next-line no-undef
|
|
341
367
|
return expect?.getState()?.currentTestName;
|
|
342
368
|
}
|
|
343
369
|
catch (e) {
|
|
@@ -380,6 +406,13 @@ function formatStep(step, shift = 0) {
|
|
|
380
406
|
}
|
|
381
407
|
return lines;
|
|
382
408
|
}
|
|
409
|
+
function getPackageVersion() {
|
|
410
|
+
const packageJsonPath = path_1.default.resolve(__dirname, '../../package.json');
|
|
411
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
|
|
412
|
+
return packageJson.version;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
module.exports.getPackageVersion = getPackageVersion;
|
|
383
416
|
|
|
384
417
|
module.exports.formatStep = formatStep;
|
|
385
418
|
|
package/lib/xmlReader.js
CHANGED
|
@@ -20,7 +20,7 @@ const uploader_js_1 = require("./uploader.js");
|
|
|
20
20
|
const debug = (0, debug_1.default)('@testomatio/reporter:xml');
|
|
21
21
|
const ridRunId = (0, crypto_1.randomUUID)();
|
|
22
22
|
const TESTOMATIO_URL = process.env.TESTOMATIO_URL || 'https://app.testomat.io';
|
|
23
|
-
const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN, TESTOMATIO_MARK_DETACHED } = process.env;
|
|
23
|
+
const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_SUITE, TESTOMATIO_MAX_STACK_TRACE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN, TESTOMATIO_MARK_DETACHED, } = process.env;
|
|
24
24
|
const options = {
|
|
25
25
|
ignoreDeclaration: true,
|
|
26
26
|
ignoreAttributes: false,
|
|
@@ -28,6 +28,7 @@ const options = {
|
|
|
28
28
|
attributeNamePrefix: '',
|
|
29
29
|
parseTagValue: true,
|
|
30
30
|
};
|
|
31
|
+
const MAX_OUTPUT_LENGTH = parseInt(TESTOMATIO_MAX_STACK_TRACE, 10) || 10000;
|
|
31
32
|
const reduceOptions = {};
|
|
32
33
|
class XmlReader {
|
|
33
34
|
constructor(opts = {}) {
|
|
@@ -75,7 +76,7 @@ class XmlReader {
|
|
|
75
76
|
/(<system-out><!\[CDATA\[)([\s\S]*?)(\]\]><\/system-out>)/g,
|
|
76
77
|
];
|
|
77
78
|
for (const regex of cutRegexes) {
|
|
78
|
-
xmlData = xmlData.replace(regex, (_, p1, p2, p3) => `${p1}${p2.substring(0,
|
|
79
|
+
xmlData = xmlData.replace(regex, (_, p1, p2, p3) => `${p1}${p2.substring(0, MAX_OUTPUT_LENGTH)}${p3}`);
|
|
79
80
|
}
|
|
80
81
|
const jsonResult = this.parser.parse(xmlData);
|
|
81
82
|
let jsonSuite;
|
|
@@ -202,7 +203,7 @@ class XmlReader {
|
|
|
202
203
|
this.tests = results.filter(t => !!t.title);
|
|
203
204
|
return {
|
|
204
205
|
status,
|
|
205
|
-
create_tests:
|
|
206
|
+
create_tests: !process.env.IGNORE_NEW_TESTS,
|
|
206
207
|
tests_count: parseInt(counters.total, 10),
|
|
207
208
|
passed_count: parseInt(counters.passed, 10),
|
|
208
209
|
skipped_count: parseInt(counters.notExecuted, 10),
|
|
@@ -313,6 +314,8 @@ class XmlReader {
|
|
|
313
314
|
this.stats.language = 'js';
|
|
314
315
|
if (file.endsWith('.ts'))
|
|
315
316
|
this.stats.language = 'ts';
|
|
317
|
+
if (file.endsWith('.cs'))
|
|
318
|
+
this.stats.language = 'csharp';
|
|
316
319
|
}
|
|
317
320
|
if (!fs_1.default.existsSync(file)) {
|
|
318
321
|
debug('Failed to open file with the source code', file);
|
|
@@ -359,13 +362,13 @@ class XmlReader {
|
|
|
359
362
|
async uploadArtifacts() {
|
|
360
363
|
for (const test of this.tests.filter(t => !!t.stack)) {
|
|
361
364
|
let files = [];
|
|
362
|
-
if (test.files?.length)
|
|
363
|
-
|
|
364
|
-
files =
|
|
365
|
+
if (!test.files?.length)
|
|
366
|
+
continue;
|
|
367
|
+
files = test.files.map(f => (path_1.default.isAbsolute(f) ? f : path_1.default.join(process.cwd(), f)));
|
|
365
368
|
if (!files.length)
|
|
366
369
|
continue;
|
|
367
370
|
const runId = this.runId || this.store.runId || Date.now().toString();
|
|
368
|
-
test.artifacts = await Promise.all(files.map(f => this.uploader.uploadFileByPath(f, [runId])));
|
|
371
|
+
test.artifacts = await Promise.all(files.map(f => this.uploader.uploadFileByPath(f, [runId, path_1.default.basename(f)])));
|
|
369
372
|
console.log(constants_js_1.APP_PREFIX, `🗄️ Uploaded ${picocolors_1.default.bold(`${files.length} artifacts`)} for test ${test.title}`);
|
|
370
373
|
}
|
|
371
374
|
}
|
|
@@ -415,14 +418,17 @@ function reduceTestCases(prev, item) {
|
|
|
415
418
|
testCases = [testCases];
|
|
416
419
|
}
|
|
417
420
|
// suite inside test case
|
|
418
|
-
|
|
419
|
-
|
|
421
|
+
const testCase = item['test-suite']?.['test-case'];
|
|
422
|
+
if (testCase) {
|
|
423
|
+
const nestedCases = Array.isArray(testCase) ? testCase : [testCase];
|
|
424
|
+
testCases.push(...nestedCases);
|
|
425
|
+
}
|
|
420
426
|
const suiteOutput = item['system-out'] || item.output || item.log || '';
|
|
421
427
|
const suiteErr = item['system-err'] || item.output || item.log || '';
|
|
422
428
|
testCases
|
|
423
429
|
.filter(t => !!t)
|
|
424
430
|
.forEach(testCaseItem => {
|
|
425
|
-
const file = testCaseItem.file || item.filepath || '';
|
|
431
|
+
const file = testCaseItem.file || item.filepath || item.fullname || '';
|
|
426
432
|
let stack = '';
|
|
427
433
|
let message = '';
|
|
428
434
|
if (testCaseItem.error)
|
|
@@ -444,7 +450,7 @@ function reduceTestCases(prev, item) {
|
|
|
444
450
|
const isParametrized = item.type === 'ParameterizedMethod';
|
|
445
451
|
const preferClassname = reduceOptions.preferClassname || isParametrized;
|
|
446
452
|
// SpecFlow config
|
|
447
|
-
let { title, tags } = fetchProperties(isParametrized ? item : testCaseItem);
|
|
453
|
+
let { title, tags, testId } = fetchProperties(isParametrized ? item : testCaseItem);
|
|
448
454
|
let example = null;
|
|
449
455
|
const suiteTitle = preferClassname ? testCaseItem.classname : item.name || testCaseItem.classname;
|
|
450
456
|
title ||= testCaseItem.name || testCaseItem.methodname || testCaseItem.classname;
|
|
@@ -454,17 +460,38 @@ function reduceTestCases(prev, item) {
|
|
|
454
460
|
example = { ...exampleMatches[1].split(',').map(v => v.trim().replace(/[^\w\s-]/g, '')) };
|
|
455
461
|
title = title.replace(/\(.*?\)/, '').trim();
|
|
456
462
|
}
|
|
457
|
-
// eslint-disable-next-line
|
|
458
463
|
stack = `${testCaseItem['system-out'] || testCaseItem.output || testCaseItem.log || ''}\n\n${stack}\n\n${suiteOutput}\n\n${suiteErr}`.trim();
|
|
459
|
-
|
|
464
|
+
if (!testId)
|
|
465
|
+
testId = (0, utils_js_1.fetchIdFromOutput)(stack);
|
|
466
|
+
if (tags?.length && !testId) {
|
|
467
|
+
testId = tags
|
|
468
|
+
.filter(t => t.startsWith('T'))
|
|
469
|
+
.map(t => `@${t}`)
|
|
470
|
+
.find(t => t.match(utils_js_1.TEST_ID_REGEX))
|
|
471
|
+
?.slice(2);
|
|
472
|
+
}
|
|
460
473
|
let status = constants_js_1.STATUS.PASSED.toString();
|
|
461
474
|
if ('failure' in testCaseItem || 'error' in testCaseItem)
|
|
462
475
|
status = constants_js_1.STATUS.FAILED;
|
|
463
476
|
if ('skipped' in testCaseItem)
|
|
464
477
|
status = constants_js_1.STATUS.SKIPPED;
|
|
478
|
+
if (testCaseItem.result && Object.values(constants_js_1.STATUS).includes(testCaseItem.result.toLowerCase())) {
|
|
479
|
+
status = testCaseItem.result.toLowerCase();
|
|
480
|
+
}
|
|
465
481
|
let rid = null;
|
|
466
482
|
if (testCaseItem.id)
|
|
467
483
|
rid = `${ridRunId}-${testCaseItem.id}`;
|
|
484
|
+
// Extract attachments
|
|
485
|
+
let files = [];
|
|
486
|
+
if (testCaseItem.attachments) {
|
|
487
|
+
const attachments = Array.isArray(testCaseItem.attachments.attachment)
|
|
488
|
+
? testCaseItem.attachments.attachment
|
|
489
|
+
: [testCaseItem.attachments.attachment];
|
|
490
|
+
files = attachments.filter(a => a && a.filePath).map(a => a.filePath);
|
|
491
|
+
}
|
|
492
|
+
// Extract files from stack trace using existing utility
|
|
493
|
+
const stackFiles = (0, utils_js_1.fetchFilesFromStackTrace)(stack);
|
|
494
|
+
files = [...new Set([...files, ...stackFiles])]; // Remove duplicates
|
|
468
495
|
prev.push({
|
|
469
496
|
rid,
|
|
470
497
|
file,
|
|
@@ -479,7 +506,9 @@ function reduceTestCases(prev, item) {
|
|
|
479
506
|
run_time: parseFloat(testCaseItem.time || testCaseItem.duration) * 1000,
|
|
480
507
|
status,
|
|
481
508
|
title,
|
|
509
|
+
root_suite_id: TESTOMATIO_SUITE,
|
|
482
510
|
suite_title: suiteTitle,
|
|
511
|
+
files,
|
|
483
512
|
});
|
|
484
513
|
});
|
|
485
514
|
return prev;
|
|
@@ -503,12 +532,18 @@ function fetchProperties(item) {
|
|
|
503
532
|
let title = '';
|
|
504
533
|
if (!item.properties)
|
|
505
534
|
return {};
|
|
506
|
-
|
|
535
|
+
// Handle both single property and array of properties
|
|
536
|
+
const properties = Array.isArray(item.properties.property)
|
|
537
|
+
? item.properties.property
|
|
538
|
+
: [item.properties.property].filter(Boolean);
|
|
539
|
+
const prop = properties.find(p => p.name === 'Description');
|
|
507
540
|
if (prop)
|
|
508
541
|
title = prop.value;
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
542
|
+
let testId = properties.find(p => p.name === 'ID')?.value;
|
|
543
|
+
if (testId?.startsWith('@'))
|
|
544
|
+
testId = testId.slice(1);
|
|
545
|
+
if (testId?.startsWith('T'))
|
|
546
|
+
testId = testId.slice(1);
|
|
547
|
+
properties.filter(p => p.name === 'Category').forEach(p => tags.push(p.value));
|
|
548
|
+
return { title, tags, testId };
|
|
514
549
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testomatio/reporter",
|
|
3
|
-
"version": "2.0.1-beta
|
|
3
|
+
"version": "2.0.1-beta.2",
|
|
4
4
|
"description": "Testomatio Reporter Client",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
"@aws-sdk/client-s3": "^3.279.0",
|
|
15
15
|
"@aws-sdk/lib-storage": "^3.279.0",
|
|
16
16
|
"@cucumber/cucumber": "^10.9.0",
|
|
17
|
-
"@octokit/rest": "^
|
|
17
|
+
"@octokit/rest": "^21.1.1",
|
|
18
18
|
"aws-sdk": "^2.1072.0",
|
|
19
|
-
"
|
|
20
|
-
"axios-retry": "^3.9.1",
|
|
19
|
+
"gaxios": ">=6.0 || >=7.0.0-rc.4 || <8",
|
|
21
20
|
"callsite-record": "^4.1.4",
|
|
22
21
|
"commander": "^12",
|
|
23
22
|
"cross-spawn": "^7.0.3",
|
|
@@ -49,7 +48,6 @@
|
|
|
49
48
|
"testcafe"
|
|
50
49
|
],
|
|
51
50
|
"scripts": {
|
|
52
|
-
"@cucumber/cucumber": "^10.9.0",
|
|
53
51
|
"clear-exportdir": "rm -rf export/",
|
|
54
52
|
"pretty": "npx prettier --check .",
|
|
55
53
|
"pretty:fix": "prettier --write .",
|
|
@@ -68,8 +66,9 @@
|
|
|
68
66
|
"test:adapter:playwright:example": "npx playwright test --config='./tests/adapter/examples/playwright/playwright.config.ts'",
|
|
69
67
|
"test:adapter:vitest:example": "npx vitest --config='./tests/adapter/examples/vitest/vitest.config.ts'",
|
|
70
68
|
"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",
|
|
71
|
-
"
|
|
72
|
-
"build": "rm -rf ./cjs &&
|
|
69
|
+
"build": "rm -rf ./cjs && tsc --module commonjs && npx tsx build/scripts/edit-js-files.js && npx tsx build/scripts/edit-package-json.js && chmod +x ./build/scripts/copy-tesmplate.sh && ./build/scripts/copy-tesmplate.sh",
|
|
70
|
+
"build:bun": "rm -rf ./cjs && bun build ./src/reporter.js ./src/bin/reportXml.js ./src/bin/startTest.js ./src/bin/uploadArtifacts.js --outdir ./cjs --target node && bun build/scripts/edit-js-files.js && bun build/scripts/edit-package-json.js && chmod +x ./build/scripts/copy-tesmplate.sh && ./build/scripts/copy-tesmplate.sh",
|
|
71
|
+
"build:watch:bun": "rm -rf ./cjs && bun build ./src/bin/reportXml.js ./src/bin/startTest.js ./src/bin/uploadArtifacts.js --outdir ./cjs --target node --watch --onSuccess \"build/scripts/post-build.js\""
|
|
73
72
|
},
|
|
74
73
|
"devDependencies": {
|
|
75
74
|
"@playwright/test": "^1.49.1",
|
|
@@ -81,8 +80,7 @@
|
|
|
81
80
|
"chai": "^4.3.6",
|
|
82
81
|
"codeceptjs": "^3.6.5",
|
|
83
82
|
"cucumber": "^6.0.7",
|
|
84
|
-
"eslint": "^
|
|
85
|
-
"eslint-config-airbnb-base": "^15.0.0",
|
|
83
|
+
"eslint": "^9.24.0",
|
|
86
84
|
"eslint-config-prettier": "^8.3.0",
|
|
87
85
|
"eslint-plugin-import": "^2.25.4",
|
|
88
86
|
"jasmine": "^5.2.0",
|
|
@@ -123,6 +121,7 @@
|
|
|
123
121
|
"./lib/adapter/mocha/mocha.js": "./lib/adapter/mocha.js",
|
|
124
122
|
"./mocha": "./lib/adapter/mocha.js",
|
|
125
123
|
"./lib/adapter/playwright.js": "./lib/adapter/playwright.js",
|
|
124
|
+
"./nightwatch": "./lib/adapter/nightwatch.js",
|
|
126
125
|
"./playwright": "./lib/adapter/playwright.js",
|
|
127
126
|
"./vitest": "./lib/adapter/vitest.js",
|
|
128
127
|
"./lib/adapter/webdriver.js": "./lib/adapter/webdriver.js",
|
package/src/adapter/codecept.js
CHANGED
|
@@ -4,7 +4,6 @@ import TestomatClient from '../client.js';
|
|
|
4
4
|
import { STATUS, APP_PREFIX, TESTOMAT_TMP_STORAGE_DIR } from '../constants.js';
|
|
5
5
|
import { getTestomatIdFromTestTitle, fileSystem } from '../utils/utils.js';
|
|
6
6
|
import { services } from '../services/index.js';
|
|
7
|
-
// eslint-disable-next-line
|
|
8
7
|
import codeceptjs from 'codeceptjs';
|
|
9
8
|
|
|
10
9
|
const debug = createDebugMessages('@testomatio/reporter:adapter:codeceptjs');
|
|
@@ -271,7 +270,6 @@ function CodeceptReporter(config) {
|
|
|
271
270
|
for (let i = 0; i < Math.max(currentMetaStep.length, metaSteps.length); i++) {
|
|
272
271
|
if (currentMetaStep[i] !== metaSteps[i]) {
|
|
273
272
|
stepShift = 2 * i;
|
|
274
|
-
// eslint-disable-next-line no-continue
|
|
275
273
|
if (!metaSteps[i]) continue;
|
|
276
274
|
if (metaSteps[i].isBDD()) {
|
|
277
275
|
// output.push(repeat(stepShift) + pc.bold(metaSteps[i].toString()) + metaSteps[i].comment);
|
|
@@ -44,7 +44,6 @@ const testomatioReporter = on => {
|
|
|
44
44
|
|
|
45
45
|
if (!error && test.displayError) {
|
|
46
46
|
error = { message: test.displayError };
|
|
47
|
-
// eslint-disable-next-line
|
|
48
47
|
error.inspect = function () {
|
|
49
48
|
return this.message;
|
|
50
49
|
};
|
|
@@ -56,7 +55,6 @@ const testomatioReporter = on => {
|
|
|
56
55
|
name: error.name,
|
|
57
56
|
inspect:
|
|
58
57
|
error.inspect ||
|
|
59
|
-
// eslint-disable-next-line
|
|
60
58
|
function () {
|
|
61
59
|
return this.message;
|
|
62
60
|
},
|
package/src/adapter/mocha.js
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import TestomatClient from '../client.js';
|
|
2
|
+
import { config } from '../config.js';
|
|
3
|
+
import { STATUS } from '../constants.js';
|
|
4
|
+
import { getTestomatIdFromTestTitle } from '../utils/utils.js';
|
|
5
|
+
|
|
6
|
+
const apiKey = config.TESTOMATIO;
|
|
7
|
+
const client = new TestomatClient({ apiKey });
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
write: async (results, options, done) => {
|
|
11
|
+
await client.createRun();
|
|
12
|
+
|
|
13
|
+
const testFiles = results.modules;
|
|
14
|
+
|
|
15
|
+
for (const fileName in testFiles) {
|
|
16
|
+
// in nightwatch: object containing tests from a single file
|
|
17
|
+
const testModule = testFiles[fileName];
|
|
18
|
+
|
|
19
|
+
// passed and failed tests (tests with assertions)
|
|
20
|
+
const completedTests = testModule.completed;
|
|
21
|
+
|
|
22
|
+
// skipped tests (skipped by user or tests without assertions)
|
|
23
|
+
const skippedTests = testModule.skipped;
|
|
24
|
+
|
|
25
|
+
const tags = testModule.tags || [];
|
|
26
|
+
|
|
27
|
+
// if test file contains multiple suites, the last suite name is used as a name 🤷♂️
|
|
28
|
+
// no other places which contain suite name (even inside test object)
|
|
29
|
+
const suiteTitle = testModule.name;
|
|
30
|
+
|
|
31
|
+
for (const testTitle in completedTests) {
|
|
32
|
+
const test = completedTests[testTitle];
|
|
33
|
+
let status;
|
|
34
|
+
switch (test.status) {
|
|
35
|
+
case 'pass':
|
|
36
|
+
status = STATUS.PASSED;
|
|
37
|
+
break;
|
|
38
|
+
case 'fail':
|
|
39
|
+
status = STATUS.FAILED;
|
|
40
|
+
break;
|
|
41
|
+
// probably not required (because skipped tests are in separate array), but just in case
|
|
42
|
+
case 'skip':
|
|
43
|
+
status = STATUS.SKIPPED;
|
|
44
|
+
console.info('Skipped test is in completed tests array:', test, 'Not expected behavior.');
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
console.error('Test status processing error:', test.status);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const testId = getTestomatIdFromTestTitle(testTitle);
|
|
51
|
+
|
|
52
|
+
client.addTestRun(status, {
|
|
53
|
+
error: { name: test.assertions?.[0]?.name, message: test.assertions?.[0]?.message, stack: test.stackTrace },
|
|
54
|
+
file: testModule.modulePath?.replace(process.cwd(), ''),
|
|
55
|
+
message: test.assertions?.[0]?.message,
|
|
56
|
+
rid: `${testModule.uuid || ''}_${testTitle || ''}`,
|
|
57
|
+
stack: test.stackTrace,
|
|
58
|
+
suite_title: suiteTitle,
|
|
59
|
+
tags,
|
|
60
|
+
test_id: testId,
|
|
61
|
+
time: test.timeMs,
|
|
62
|
+
title: testTitle,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// just array with skipped tests titles, no any other info
|
|
67
|
+
for (const testTitle of skippedTests) {
|
|
68
|
+
client.addTestRun(STATUS.SKIPPED, {
|
|
69
|
+
suite_title: suiteTitle,
|
|
70
|
+
tags,
|
|
71
|
+
rid: `${testModule.uuid || ''}_${testTitle || ''}`,
|
|
72
|
+
title: testTitle,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @type {'passed' | 'failed' | 'finished'}
|
|
79
|
+
*/
|
|
80
|
+
let runStatus = 'finished';
|
|
81
|
+
if (results.failed) runStatus = 'failed';
|
|
82
|
+
else if (results.passed) runStatus = 'passed';
|
|
83
|
+
|
|
84
|
+
await client.updateRunStatus(runStatus);
|
|
85
|
+
|
|
86
|
+
done();
|
|
87
|
+
},
|
|
88
|
+
};
|
package/src/adapter/webdriver.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import WDIOReporter, { RunnerStats } from '@wdio/reporter';
|
|
1
|
+
import { default as WDIOReporter, RunnerStats } from '@wdio/reporter';
|
|
3
2
|
import TestomatClient from '../client.js';
|
|
4
3
|
import { getTestomatIdFromTestTitle, fileSystem } from '../utils/utils.js';
|
|
5
4
|
import { services } from '../services/index.js';
|
|
@@ -82,6 +81,7 @@ class WebdriverReporter extends WDIOReporter {
|
|
|
82
81
|
.map(el => Buffer.from(el.result.value, 'base64'));
|
|
83
82
|
|
|
84
83
|
await this.client.addTestRun(state, {
|
|
84
|
+
rid: test.uid || '',
|
|
85
85
|
manuallyAttachedArtifacts: test.artifacts,
|
|
86
86
|
error,
|
|
87
87
|
logs: test.logs,
|
package/src/bin/cli.js
CHANGED
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { spawn } from 'cross-spawn';
|
|
5
|
-
import glob from 'glob';
|
|
5
|
+
import { glob } from 'glob';
|
|
6
6
|
import createDebugMessages from 'debug';
|
|
7
7
|
import TestomatClient from '../client.js';
|
|
8
8
|
import XmlReader from '../xmlReader.js';
|
|
9
9
|
import { APP_PREFIX, STATUS } from '../constants.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getPackageVersion } from '../utils/utils.js';
|
|
11
11
|
import { config } from '../config.js';
|
|
12
12
|
import { readLatestRunId } from '../utils/utils.js';
|
|
13
13
|
import pc from 'picocolors';
|
|
14
14
|
import { filesize as prettyBytes } from 'filesize';
|
|
15
15
|
import dotenv from 'dotenv';
|
|
16
|
+
import Replay from '../replay.js';
|
|
16
17
|
|
|
17
18
|
const debug = createDebugMessages('@testomatio/reporter:xml-cli');
|
|
19
|
+
const version = getPackageVersion();
|
|
18
20
|
console.log(pc.cyan(pc.bold(` 🤩 Testomat.io Reporter v${version}`)));
|
|
19
21
|
const program = new Command();
|
|
20
22
|
|
|
@@ -120,6 +122,28 @@ program
|
|
|
120
122
|
}
|
|
121
123
|
});
|
|
122
124
|
|
|
125
|
+
// program
|
|
126
|
+
// .command('xml')
|
|
127
|
+
// .description('Parse XML reports and upload to Testomat.io')
|
|
128
|
+
// .argument('<pattern>', 'XML file pattern')
|
|
129
|
+
// .option('-d, --dir <dir>', 'Project directory')
|
|
130
|
+
// .option('--java-tests [java-path]', 'Load Java tests from path, by default: src/test/java')
|
|
131
|
+
// .option('--lang <lang>', 'Language used (python, ruby, java)')
|
|
132
|
+
// .option('--timelimit <time>', 'default time limit in seconds to kill a stuck process')
|
|
133
|
+
// .action(async (pattern, opts) => {
|
|
134
|
+
// if (!pattern.endsWith('.xml')) {
|
|
135
|
+
// pattern += '.xml';
|
|
136
|
+
// }
|
|
137
|
+
// let { javaTests, lang } = opts;
|
|
138
|
+
// if (javaTests === true) javaTests = 'src/test/java';
|
|
139
|
+
// lang = lang?.toLowerCase();
|
|
140
|
+
// const runReader = new XmlReader({ javaTests, lang });
|
|
141
|
+
// const files = glob.sync(pattern, { cwd: opts.dir || process.cwd() });
|
|
142
|
+
// if (!files.length) {
|
|
143
|
+
// console.log(APP_PREFIX, `Report can't be created. No XML files found 😥`);
|
|
144
|
+
// process.exit(1);
|
|
145
|
+
// }
|
|
146
|
+
|
|
123
147
|
program
|
|
124
148
|
.command('xml')
|
|
125
149
|
.description('Parse XML reports and upload to Testomat.io')
|
|
@@ -273,6 +297,50 @@ program
|
|
|
273
297
|
}
|
|
274
298
|
});
|
|
275
299
|
|
|
300
|
+
program
|
|
301
|
+
.command('replay')
|
|
302
|
+
.description('Replay test data from debug file and re-send to Testomat.io')
|
|
303
|
+
.argument('[debug-file]', 'Path to debug file (defaults to /tmp/testomatio.debug.latest.json)')
|
|
304
|
+
.option('--dry-run', 'Preview the data without sending to Testomat.io')
|
|
305
|
+
.action(async (debugFile, opts) => {
|
|
306
|
+
try {
|
|
307
|
+
const replayService = new Replay({
|
|
308
|
+
apiKey: config.TESTOMATIO,
|
|
309
|
+
dryRun: opts.dryRun,
|
|
310
|
+
onLog: (message) => console.log(APP_PREFIX, message),
|
|
311
|
+
onError: (message) => console.error(APP_PREFIX, '⚠️ ', message),
|
|
312
|
+
onProgress: ({ current, total }) => {
|
|
313
|
+
if (current % 10 === 0 || current === total) {
|
|
314
|
+
console.log(APP_PREFIX, `📊 Progress: ${current}/${total} tests processed`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
const result = await replayService.replay(debugFile);
|
|
320
|
+
|
|
321
|
+
if (result.dryRun) {
|
|
322
|
+
console.log(APP_PREFIX, '🔍 Dry run completed:');
|
|
323
|
+
console.log(APP_PREFIX, ` - Tests found: ${result.testsCount}`);
|
|
324
|
+
console.log(APP_PREFIX, ` - Environment variables: ${Object.keys(result.envVars).length}`);
|
|
325
|
+
console.log(APP_PREFIX, ` - Run parameters:`, result.runParams);
|
|
326
|
+
console.log(APP_PREFIX, ' Use without --dry-run to actually send the data');
|
|
327
|
+
} else {
|
|
328
|
+
console.log(APP_PREFIX, `✅ Successfully replayed ${result.successCount}/${result.testsCount} tests`);
|
|
329
|
+
if (result.failureCount > 0) {
|
|
330
|
+
console.log(APP_PREFIX, `⚠️ ${result.failureCount} tests failed to upload`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
process.exit(0);
|
|
335
|
+
} catch (err) {
|
|
336
|
+
console.error(APP_PREFIX, '❌ Error replaying debug data:', err.message);
|
|
337
|
+
if (err.message.includes('Debug file not found')) {
|
|
338
|
+
console.error(APP_PREFIX, '💡 Hint: Run tests with TESTOMATIO_DEBUG=1 to generate debug files');
|
|
339
|
+
}
|
|
340
|
+
process.exit(1);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
|
|
276
344
|
program.parse(process.argv);
|
|
277
345
|
|
|
278
346
|
if (!process.argv.slice(2).length) {
|
package/src/bin/reportXml.js
CHANGED
|
@@ -5,8 +5,11 @@ import { glob } from 'glob';
|
|
|
5
5
|
import createDebugMessages from 'debug';
|
|
6
6
|
import { APP_PREFIX } from '../constants.js';
|
|
7
7
|
import XmlReader from '../xmlReader.js';
|
|
8
|
-
import {
|
|
8
|
+
import { getPackageVersion } from '../utils/utils.js';
|
|
9
9
|
import dotenv from 'dotenv';
|
|
10
|
+
import path from 'path';
|
|
11
|
+
|
|
12
|
+
const version = getPackageVersion();
|
|
10
13
|
|
|
11
14
|
const debug = createDebugMessages('@testomatio/reporter:xml-cli');
|
|
12
15
|
console.log(pc.cyan(pc.bold(` 🤩 Testomat.io XML Reporter v${version}`)));
|
package/src/bin/startTest.js
CHANGED
|
@@ -4,10 +4,11 @@ import { Command } from 'commander';
|
|
|
4
4
|
import pc from 'picocolors';
|
|
5
5
|
import TestomatClient from '../client.js';
|
|
6
6
|
import { APP_PREFIX, STATUS } from '../constants.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getPackageVersion } from '../utils/utils.js';
|
|
8
8
|
import { config } from '../config.js';
|
|
9
9
|
import dotenv from 'dotenv';
|
|
10
10
|
|
|
11
|
+
const version = getPackageVersion();
|
|
11
12
|
console.log(pc.cyan(pc.bold(` 🤩 Testomat.io Reporter v${version}`)));
|
|
12
13
|
const program = new Command();
|
|
13
14
|
|