@testomatio/reporter 2.3.7-beta.1-xml-import → 2.3.7-beta.2-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.
@@ -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 = step.toString(); // Use built-in toString
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;
@@ -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;
@@ -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', (code) => {
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
- // @ts-ignore this line will be removed in compiled code, because __dirname is defined in commonjs
74
- const pathToPackageJSON = path_1.default.join(__dirname, '../package.json');
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?.trim();
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
- // Don't override example if it already exists from NUnit XML processing
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
- // Keep as array for consistency with NUnit XML processing
17
- t.example = exampleMatch[1].split(',').map(param => param.trim());
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
+ // For runs: keep full title with parameters for display
23
+ // The example field will be used for grouping on import
24
+ // Do NOT remove parameters from title
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
- title: isParameterized ? testName : methodName || testName,
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
  }
@@ -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 start-test-run --finish`);
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('');