testomatio-reporter-cli 2.15.0 → 2.17.0-beta

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testomatio-reporter-cli",
3
- "version": "2.15.0",
3
+ "version": "2.17.0-beta",
4
4
  "description": "Yarn Berry compatible standalone CLI for @testomatio/reporter",
5
5
  "type": "module",
6
6
  "bin": {
@@ -34,7 +34,9 @@ const HOOK_EXECUTION_ORDER = {
34
34
  // codeceptjs workers are self-contained
35
35
  dataStorage.isFileStorage = false;
36
36
 
37
- const DATA_REGEXP = /[|\s]+?(\{".*\}|\[.*\])/;
37
+ // CodeceptJS appends the serialized data row of a data-driven test to its title
38
+ const DATA_REGEXP = / \| (\{.*\}|\[.*\]|null|"(?:\\.|[^"\\])*")((?:\s+@[a-zA-Z0-9-_]+)*)$/;
39
+ const PLACEHOLDER_REGEXP = /\$\{([\w_]+)\}/g;
38
40
 
39
41
  if (MAJOR_VERSION < 3) {
40
42
  console.log('🔴 This reporter works with CodeceptJS 3+, please update your tests');
@@ -349,15 +351,34 @@ function stripExampleFromTitle(title) {
349
351
  const res = title.match(DATA_REGEXP);
350
352
  if (!res) return { title, example: null };
351
353
 
354
+ let example = null;
355
+ let exampleParsed = false;
352
356
  try {
353
- const example = JSON.parse(res[1]);
354
- title = title.replace(DATA_REGEXP, '').trim();
355
- return { title, example };
357
+ example = JSON.parse(res[1]);
358
+ exampleParsed = true;
356
359
  } catch (e) {
357
- // If JSON parsing fails, return title without example
358
- debug('Failed to parse example JSON:', res[1], e.message);
359
- return { title: title.replace(DATA_REGEXP, '').trim(), example: null };
360
+ try {
361
+ example = JSON.parse(res[1].slice(1, -1));
362
+ exampleParsed = true;
363
+ } catch (e2) {
364
+ debug('Failed to parse example from title:', res[1]);
365
+ }
366
+ }
367
+
368
+ let baseTitle = title.slice(0, res.index).trim();
369
+ if (exampleParsed) {
370
+ baseTitle = baseTitle.replace(PLACEHOLDER_REGEXP, (placeholder, key) => {
371
+ if (key === 'current') return formatExample(example);
372
+ if (!Object.hasOwn(example ?? {}, key)) return placeholder;
373
+ return formatExample(example[key]);
374
+ });
360
375
  }
376
+ return { title: `${baseTitle}${res[2]}`, example };
377
+ }
378
+
379
+ function formatExample(example) {
380
+ if (example !== null && typeof example === 'object') return JSON.stringify(example);
381
+ return String(example);
361
382
  }
362
383
 
363
384
  function stripTagsFromTitle(title) {
@@ -88,12 +88,15 @@ class TestomatioPipe {
88
88
  this.store = store || {};
89
89
  this.title = params.title || process.env.TESTOMATIO_TITLE;
90
90
  this.sharedRun = !!process.env.TESTOMATIO_SHARED_RUN;
91
+ this.sharedRunShards = process.env.TESTOMATIO_SHARDS
92
+ ? parseInt(process.env.TESTOMATIO_SHARDS, 10) || undefined
93
+ : undefined;
91
94
  this.sharedRunTimeout = process.env.TESTOMATIO_SHARED_RUN_TIMEOUT
92
95
  ? parseInt(process.env.TESTOMATIO_SHARED_RUN_TIMEOUT, 10)
93
96
  : undefined;
94
97
 
95
- if (this.sharedRunTimeout && !this.sharedRun) {
96
- debug('Auto-enabling sharedRun because sharedRunTimeout is set');
98
+ if ((this.sharedRunTimeout || this.sharedRunShards) && !this.sharedRun) {
99
+ debug('Auto-enabling sharedRun because sharedRunTimeout or sharedRunShards is set');
97
100
  this.sharedRun = true;
98
101
  }
99
102
 
@@ -323,6 +326,7 @@ class TestomatioPipe {
323
326
  label: this.label,
324
327
  shared_run: this.sharedRun,
325
328
  shared_run_timeout: this.sharedRunTimeout,
329
+ shared_run_shards: this.sharedRunShards,
326
330
  kind: params.kind,
327
331
  status: params.status,
328
332
  configuration,
@@ -570,6 +574,7 @@ class TestomatioPipe {
570
574
  if (status === STATUS.FINISHED) status_event = 'finish';
571
575
  if (status === STATUS.PASSED) status_event = 'pass';
572
576
  if (status === STATUS.FAILED) status_event = 'fail';
577
+ if (this.sharedRun) status_event = 'finish';
573
578
 
574
579
  try {
575
580
  if (this.runId && !this.proceed) {