@testomatio/reporter 2.19.0 → 2.21.0

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.
Files changed (62) hide show
  1. package/lib/adapter/codecept.js +26 -2
  2. package/lib/adapter/cucumber/current.js +1 -0
  3. package/lib/adapter/cypress-plugin/index.js +1 -0
  4. package/lib/adapter/e2e.d.ts +49 -0
  5. package/lib/adapter/e2e.js +254 -0
  6. package/lib/adapter/jasmine.js +1 -0
  7. package/lib/adapter/jest.js +1 -0
  8. package/lib/adapter/mocha.d.ts +4 -1
  9. package/lib/adapter/mocha.js +123 -122
  10. package/lib/adapter/nightwatch.js +1 -0
  11. package/lib/adapter/playwright.js +33 -1
  12. package/lib/adapter/vitest.js +5 -1
  13. package/lib/adapter/webdriver.js +45 -2
  14. package/lib/allureReader.d.ts +4 -1
  15. package/lib/allureReader.js +2 -1
  16. package/lib/bin/cli.js +212 -19
  17. package/lib/client.d.ts +1 -0
  18. package/lib/client.js +12 -3
  19. package/lib/data-storage.js +4 -3
  20. package/lib/fetch/report.d.ts +31 -0
  21. package/lib/fetch/report.js +81 -0
  22. package/lib/fetch/testruns.d.ts +133 -0
  23. package/lib/fetch/testruns.js +286 -0
  24. package/lib/pipe/markdown.d.ts +1 -0
  25. package/lib/pipe/markdown.js +7 -0
  26. package/lib/pipe/testomatio.js +17 -1
  27. package/lib/replay.js +1 -0
  28. package/lib/reporter-functions.js +39 -0
  29. package/lib/uploader.d.ts +17 -0
  30. package/lib/uploader.js +75 -1
  31. package/lib/utils/detectRunner.d.ts +23 -0
  32. package/lib/utils/detectRunner.js +149 -0
  33. package/lib/utils/pipe_utils.d.ts +16 -3
  34. package/lib/utils/pipe_utils.js +45 -4
  35. package/lib/xmlReader.js +2 -0
  36. package/package.json +8 -3
  37. package/src/adapter/codecept.js +24 -2
  38. package/src/adapter/cucumber/current.js +2 -0
  39. package/src/adapter/cypress-plugin/index.js +2 -0
  40. package/src/adapter/e2e.js +248 -0
  41. package/src/adapter/jasmine.js +2 -0
  42. package/src/adapter/jest.js +2 -0
  43. package/src/adapter/mocha.js +146 -145
  44. package/src/adapter/nightwatch.js +2 -0
  45. package/src/adapter/playwright.js +33 -1
  46. package/src/adapter/vitest.js +6 -1
  47. package/src/adapter/webdriver.js +46 -2
  48. package/src/allureReader.js +2 -1
  49. package/src/bin/cli.js +246 -18
  50. package/src/client.js +11 -3
  51. package/src/data-storage.js +4 -3
  52. package/src/fetch/report.js +86 -0
  53. package/src/fetch/testruns.js +283 -0
  54. package/src/pipe/markdown.js +7 -0
  55. package/src/pipe/testomatio.js +27 -1
  56. package/src/replay.js +1 -0
  57. package/src/reporter-functions.js +41 -0
  58. package/src/uploader.js +81 -1
  59. package/src/utils/detectRunner.js +151 -0
  60. package/src/utils/pipe_utils.js +45 -4
  61. package/src/xmlReader.js +3 -0
  62. package/types/types.d.ts +1 -0
@@ -366,17 +366,18 @@ function formatRunOutput(store, format) {
366
366
 
367
367
  /**
368
368
  * Format the runs fetched via the `fetch` command for machine-readable output.
369
- * `json` prints the full array of run objects; `id` prints one run id per line;
369
+ * `json` prints the full array of run objects (a single object for one run); `id` prints one run id per line;
370
370
  * any other format prints a human-readable multi-line summary per run.
371
371
  *
372
- * @param {{data?: Array}} body - Parsed response body from GET /api/v2/:project/runs.
372
+ * @param {{data?: Array|Object}} body - Parsed response body from GET /api/v2/:project/runs[/:id].
373
373
  * @param {string} [format] - Value of the CLI `--format` option.
374
374
  * @returns {string}
375
375
  */
376
376
  function formatFetchRunsOutput(body, format) {
377
- const runs = body?.data || [];
377
+ const data = body?.data || [];
378
+ const runs = [data].flat();
378
379
 
379
- if (format === 'json') return JSON.stringify(runs, null, 2);
380
+ if (format === 'json') return JSON.stringify(data, null, 2);
380
381
 
381
382
  if (format === 'id') return runs.map(run => run.id).filter(Boolean).join('\n');
382
383
 
@@ -384,6 +385,7 @@ function formatFetchRunsOutput(body, format) {
384
385
  .map(run => {
385
386
  const lines = [`* ID: ${run.id}`];
386
387
  if (run.title) lines.push(` title: ${run.title}`);
388
+ if (run.rungroup_id) lines.push(` rungroup: ${run.rungroup_id}`);
387
389
  if (run.launched_at) lines.push(` started at: ${run.launched_at}`);
388
390
  if (run.finished_at) lines.push(` finished at: ${run.finished_at}`);
389
391
  if (run.passed_count != null) lines.push(` passed: ${run.passed_count} tests`);
@@ -397,6 +399,44 @@ function formatFetchRunsOutput(body, format) {
397
399
  .join('\n');
398
400
  }
399
401
 
402
+ // filterParam keys of the runs page which are API params on their own; the rest go under filter[...]
403
+ const RUNS_PAGE_PARAMS = ['search', 'tql', 'groupId'];
404
+
405
+ /**
406
+ * Parse a Testomat.io app URL of a run (/projects/:project/runs/:id)
407
+ * or of a runs page (/projects/:project/runs?filterParam=...) into API v2 request parts.
408
+ *
409
+ * @param {string} pageUrl
410
+ * @returns {{baseUrl: string, project: string, runId?: string, params: string[][]}|null}
411
+ */
412
+ function parseRunsUrl(pageUrl) {
413
+ let url;
414
+ try {
415
+ url = new URL(pageUrl);
416
+ } catch (e) {
417
+ return null;
418
+ }
419
+
420
+ const match = url.pathname.match(/\/projects\/([^/]+)\/runs(?:\/([^/]+))?\/?$/);
421
+ if (!match) return null;
422
+
423
+ const [, project, runId] = match;
424
+ const params = [];
425
+
426
+ for (const [key, value] of new URLSearchParams(url.searchParams.get('filterParam') || '')) {
427
+ // "groups" only switches the page to the grouped view
428
+ if (!value || key === 'groups') continue;
429
+ if (RUNS_PAGE_PARAMS.includes(key)) {
430
+ params.push([key, value]);
431
+ continue;
432
+ }
433
+ const [name, ...nested] = key.split('[');
434
+ params.push([`filter[${name}]${nested.map(part => `[${part}`).join('')}`, value]);
435
+ }
436
+
437
+ return { baseUrl: url.origin, project, runId, params };
438
+ }
439
+
400
440
  export {
401
441
  updateFilterType,
402
442
  parseFilterParams,
@@ -413,6 +453,7 @@ export {
413
453
  formatFilterListIds,
414
454
  formatRunOutput,
415
455
  formatFetchRunsOutput,
456
+ parseRunsUrl,
416
457
  getObjectSize,
417
458
  splitTestsIntoChunks,
418
459
  };
package/src/xmlReader.js CHANGED
@@ -499,6 +499,9 @@ class XmlReader {
499
499
  this.adapter.formatTest(t);
500
500
 
501
501
  t.title = humanize(t.title);
502
+
503
+ // meta must always include reporter version and adapter used
504
+ t.meta = { ...t.meta, reporterVersion: this.version, adapter: 'xml' };
502
505
  });
503
506
  }
504
507
 
package/types/types.d.ts CHANGED
@@ -374,6 +374,7 @@ declare global {
374
374
  testomatioDataStore?: any;
375
375
  TESTOMATIO_LOGGER_CONSOLE_INTERCEPTED?: boolean;
376
376
  testomatioTestTitle?: string;
377
+ TESTOMATIO_ADAPTER?: string;
377
378
  }
378
379
  }
379
380
  }