@testomatio/reporter 2.3.7-beta.1-xml-import → 2.3.7-beta.3-xml-import
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 +22 -2
- package/lib/bin/cli.js +1 -1
- package/lib/bin/reportXml.js +1 -1
- package/lib/bin/startTest.js +3 -3
- package/lib/client.js +7 -3
- package/lib/junit-adapter/csharp.js +10 -6
- package/lib/junit-adapter/nunit-parser.js +14 -2
- package/lib/pipe/testomatio.js +1 -2
- package/lib/template/testomatio.hbs +1366 -1026
- package/lib/utils/utils.d.ts +1 -0
- package/lib/utils/utils.js +89 -26
- package/lib/xmlReader.d.ts +21 -0
- package/lib/xmlReader.js +56 -49
- package/package.json +1 -1
- package/src/adapter/codecept.js +27 -3
- package/src/bin/cli.js +1 -1
- package/src/bin/reportXml.js +1 -1
- package/src/bin/startTest.js +5 -5
- package/src/client.js +8 -5
- package/src/junit-adapter/csharp.js +11 -6
- package/src/junit-adapter/nunit-parser.js +15 -2
- package/src/pipe/testomatio.js +1 -3
- package/src/template/testomatio.hbs +1366 -1026
- package/src/utils/utils.js +91 -22
- package/src/xmlReader.js +66 -44
package/lib/adapter/codecept.js
CHANGED
|
@@ -110,6 +110,25 @@ function CodeceptReporter(config) {
|
|
|
110
110
|
output.stepShift = 2;
|
|
111
111
|
index_js_1.services.setContext(null);
|
|
112
112
|
});
|
|
113
|
+
// mark as failed all tests inside the failed hook
|
|
114
|
+
event.dispatcher.on(event.hook.failed, hook => {
|
|
115
|
+
if (hook.name !== 'BeforeSuiteHook')
|
|
116
|
+
return;
|
|
117
|
+
const suite = hook.runnable.parent;
|
|
118
|
+
if (!suite)
|
|
119
|
+
return;
|
|
120
|
+
const error = hook?.ctx?.currentTest?.err;
|
|
121
|
+
for (const test of suite.tests) {
|
|
122
|
+
client.addTestRun('failed', {
|
|
123
|
+
...stripExampleFromTitle(test.title),
|
|
124
|
+
rid: test.uid,
|
|
125
|
+
test_id: (0, utils_js_1.getTestomatIdFromTestTitle)(test.title),
|
|
126
|
+
suite_title: stripTagsFromTitle(suite.title),
|
|
127
|
+
error,
|
|
128
|
+
time: hook?.runnable?.duration,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
113
132
|
event.dispatcher.on(event.suite.before, suite => {
|
|
114
133
|
data_storage_js_1.dataStorage.setContext(suite.fullTitle());
|
|
115
134
|
});
|
|
@@ -379,7 +398,7 @@ function formatCodeceptStep(step) {
|
|
|
379
398
|
if (!step)
|
|
380
399
|
return null;
|
|
381
400
|
const category = step.constructor.name === 'HelperStep' ? 'framework' : 'user';
|
|
382
|
-
const title =
|
|
401
|
+
const title = (0, utils_js_1.truncate)(step); // Use built-in toString
|
|
383
402
|
const duration = step.duration || 0; // Use built-in duration
|
|
384
403
|
const formattedStep = {
|
|
385
404
|
category,
|
|
@@ -403,10 +422,11 @@ function formatHookStep(step) {
|
|
|
403
422
|
if (step.actor && step.name) {
|
|
404
423
|
title = `${step.actor} ${step.name}`;
|
|
405
424
|
if (step.args && step.args.length > 0) {
|
|
406
|
-
const argsStr = step.args.map(arg => JSON.stringify(arg)).join(', ');
|
|
425
|
+
const argsStr = step.args.map(arg => (0, utils_js_1.truncate)(JSON.stringify(arg))).join(', ');
|
|
407
426
|
title += ` ${argsStr}`;
|
|
408
427
|
}
|
|
409
428
|
}
|
|
429
|
+
title = (0, utils_js_1.truncate)(title);
|
|
410
430
|
return {
|
|
411
431
|
category: 'hook',
|
|
412
432
|
title,
|
package/lib/bin/cli.js
CHANGED
|
@@ -145,7 +145,7 @@ program
|
|
|
145
145
|
.option('--lang <lang>', 'Language used (python, ruby, java)')
|
|
146
146
|
.option('--timelimit <time>', 'default time limit in seconds to kill a stuck process')
|
|
147
147
|
.action(async (pattern, opts) => {
|
|
148
|
-
if (!pattern.endsWith('.xml')) {
|
|
148
|
+
if (!pattern.endsWith('.xml') && !pattern.includes('*')) {
|
|
149
149
|
pattern += '.xml';
|
|
150
150
|
}
|
|
151
151
|
let { javaTests, lang } = opts;
|
package/lib/bin/reportXml.js
CHANGED
|
@@ -25,7 +25,7 @@ program
|
|
|
25
25
|
.option('--timelimit <time>', 'default time limit in seconds to kill a stuck process')
|
|
26
26
|
.option('--env-file <envfile>', 'Load environment variables from env file')
|
|
27
27
|
.action(async (pattern, opts) => {
|
|
28
|
-
if (!pattern.endsWith('.xml')) {
|
|
28
|
+
if (!pattern.endsWith('.xml') && !pattern.includes('*')) {
|
|
29
29
|
pattern += '.xml';
|
|
30
30
|
}
|
|
31
31
|
let { javaTests, lang } = opts;
|
package/lib/bin/startTest.js
CHANGED
|
@@ -35,7 +35,7 @@ while (i < args.length) {
|
|
|
35
35
|
newArgs[0] = 'start';
|
|
36
36
|
}
|
|
37
37
|
else if (arg === '--finish') {
|
|
38
|
-
// Map --finish to finish command
|
|
38
|
+
// Map --finish to finish command
|
|
39
39
|
newArgs[0] = 'finish';
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
@@ -46,8 +46,8 @@ while (i < args.length) {
|
|
|
46
46
|
}
|
|
47
47
|
// Execute the main CLI with mapped arguments
|
|
48
48
|
const child = (0, node_child_process_1.spawn)(process.execPath, [cliPath, ...newArgs], {
|
|
49
|
-
stdio: 'inherit'
|
|
49
|
+
stdio: 'inherit',
|
|
50
50
|
});
|
|
51
|
-
child.on('exit',
|
|
51
|
+
child.on('exit', code => {
|
|
52
52
|
process.exit(code);
|
|
53
53
|
});
|
package/lib/client.js
CHANGED
|
@@ -70,8 +70,8 @@ class Client {
|
|
|
70
70
|
this.pipeStore = {};
|
|
71
71
|
this.runId = '';
|
|
72
72
|
this.queue = Promise.resolve();
|
|
73
|
-
//
|
|
74
|
-
const pathToPackageJSON = path_1.default.join(
|
|
73
|
+
// Get package.json path - use a simple approach that works in both environments
|
|
74
|
+
const pathToPackageJSON = path_1.default.join(process.cwd(), 'package.json');
|
|
75
75
|
try {
|
|
76
76
|
this.version = JSON.parse(fs_1.default.readFileSync(pathToPackageJSON).toString()).version;
|
|
77
77
|
console.log(constants_js_1.APP_PREFIX, `Testomatio Reporter v${this.version}`);
|
|
@@ -329,7 +329,11 @@ class Client {
|
|
|
329
329
|
*/
|
|
330
330
|
formatLogs({ error, steps, logs }) {
|
|
331
331
|
error = error?.trim();
|
|
332
|
-
logs = logs
|
|
332
|
+
logs = logs
|
|
333
|
+
?.trim()
|
|
334
|
+
.split('\n')
|
|
335
|
+
.map(l => (0, utils_js_1.truncate)(l))
|
|
336
|
+
.join('\n');
|
|
333
337
|
if (Array.isArray(steps)) {
|
|
334
338
|
steps = steps
|
|
335
339
|
.map(step => (0, utils_js_1.formatStep)(step))
|
|
@@ -7,17 +7,21 @@ const path_1 = __importDefault(require("path"));
|
|
|
7
7
|
const adapter_js_1 = __importDefault(require("./adapter.js"));
|
|
8
8
|
class CSharpAdapter extends adapter_js_1.default {
|
|
9
9
|
formatTest(t) {
|
|
10
|
-
//
|
|
11
|
-
// The xmlReader.js already extracts parameters correctly from <arguments>
|
|
10
|
+
// Extract example from title if not already present
|
|
12
11
|
if (!t.example) {
|
|
13
|
-
const title = t.title.replace(/\(.*?\)/, '').trim();
|
|
14
12
|
const exampleMatch = t.title.match(/\((.*?)\)/);
|
|
15
13
|
if (exampleMatch) {
|
|
16
|
-
//
|
|
17
|
-
|
|
14
|
+
// Extract parameters as object with numeric keys for API
|
|
15
|
+
const params = exampleMatch[1].split(',').map(param => param.trim());
|
|
16
|
+
t.example = {};
|
|
17
|
+
params.forEach((param, index) => {
|
|
18
|
+
t.example[index] = param;
|
|
19
|
+
});
|
|
18
20
|
}
|
|
19
|
-
t.title = title.trim();
|
|
20
21
|
}
|
|
22
|
+
// Remove parameters from title to avoid duplicates in Test Suite
|
|
23
|
+
// The example field will be used for grouping on import
|
|
24
|
+
t.title = t.title.replace(/\(.*?\)/, '').trim();
|
|
21
25
|
const suite = t.suite_title.split('.');
|
|
22
26
|
t.suite_title = suite.pop();
|
|
23
27
|
t.file = namespaceToFileName(t.file);
|
|
@@ -198,8 +198,19 @@ class NUnitXmlParser {
|
|
|
198
198
|
}
|
|
199
199
|
// Build file path from suite path and class name
|
|
200
200
|
const filePath = this.buildFilePath(suitePath, className, parentSuite);
|
|
201
|
+
// For parameterized tests, format example as expected by Testomatio API
|
|
202
|
+
// Convert array of parameters to object with numeric keys
|
|
203
|
+
let example = null;
|
|
204
|
+
if (isParameterized && parameters.length > 0) {
|
|
205
|
+
example = {};
|
|
206
|
+
parameters.forEach((param, index) => {
|
|
207
|
+
example[index] = param;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
201
210
|
return {
|
|
202
|
-
|
|
211
|
+
// For runs: use full test name with parameters (TestBooleanValue(true))
|
|
212
|
+
// For import: API will group by base name using the example field
|
|
213
|
+
title: testName, // Full name with parameters for run display
|
|
203
214
|
methodName: baseMethodName || methodName || testName,
|
|
204
215
|
fullName: fullName,
|
|
205
216
|
suitePath: suitePath,
|
|
@@ -213,8 +224,9 @@ class NUnitXmlParser {
|
|
|
213
224
|
create: true,
|
|
214
225
|
retry: false,
|
|
215
226
|
// Parameterized test metadata
|
|
227
|
+
example: example, // Parameters as object for API grouping
|
|
216
228
|
isParameterized: isParameterized,
|
|
217
|
-
parameters: parameters,
|
|
229
|
+
parameters: parameters, // Keep original array for reference
|
|
218
230
|
baseMethodName: baseMethodName,
|
|
219
231
|
};
|
|
220
232
|
}
|
package/lib/pipe/testomatio.js
CHANGED
|
@@ -414,7 +414,6 @@ class TestomatioPipe {
|
|
|
414
414
|
tests: params.tests,
|
|
415
415
|
},
|
|
416
416
|
});
|
|
417
|
-
debug(constants_js_1.APP_PREFIX, '✅ Testrun finished');
|
|
418
417
|
if (this.runUrl) {
|
|
419
418
|
console.log(constants_js_1.APP_PREFIX, '📊 Report Saved. Report URL:', picocolors_1.default.magenta(this.runUrl));
|
|
420
419
|
}
|
|
@@ -425,7 +424,7 @@ class TestomatioPipe {
|
|
|
425
424
|
if (this.runUrl && this.proceed) {
|
|
426
425
|
const notFinishedMessage = picocolors_1.default.yellow(picocolors_1.default.bold('Run was not finished because of $TESTOMATIO_PROCEED'));
|
|
427
426
|
console.log(constants_js_1.APP_PREFIX, `📊 ${notFinishedMessage}. Report URL: ${picocolors_1.default.magenta(this.runUrl)}`);
|
|
428
|
-
console.log(constants_js_1.APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx
|
|
427
|
+
console.log(constants_js_1.APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx @testomatio/reporter finish`);
|
|
429
428
|
}
|
|
430
429
|
if (this.hasUnmatchedTests) {
|
|
431
430
|
console.log('');
|