@testomatio/reporter 2.3.6-beta.2-fix-beforesuite → 2.3.6

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/client.js CHANGED
@@ -329,7 +329,7 @@ class Client {
329
329
  */
330
330
  formatLogs({ error, steps, logs }) {
331
331
  error = error?.trim();
332
- logs = logs?.trim();
332
+ logs = logs?.trim().split('\n').map(l => (0, utils_js_1.truncate)(l)).join('\n');
333
333
  if (Array.isArray(steps)) {
334
334
  steps = steps
335
335
  .map(step => (0, utils_js_1.formatStep)(step))
@@ -410,7 +410,6 @@ class TestomatioPipe {
410
410
  tests: params.tests,
411
411
  }
412
412
  });
413
- console.log(constants_js_1.APP_PREFIX, '✅ Testrun finished');
414
413
  if (this.runUrl) {
415
414
  console.log(constants_js_1.APP_PREFIX, '📊 Report Saved. Report URL:', picocolors_1.default.magenta(this.runUrl));
416
415
  }
@@ -2,6 +2,7 @@ export function getPackageVersion(): any;
2
2
  export const TEST_ID_REGEX: RegExp;
3
3
  export const SUITE_ID_REGEX: RegExp;
4
4
  export function ansiRegExp(): RegExp;
5
+ export function truncate(s: any, size?: number): any;
5
6
  export function cleanLatestRunId(): any;
6
7
  export function isSameTest(test: any, t: any): boolean;
7
8
  export function fetchSourceCode(contents: any, opts?: {}): string;
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.validateSuiteId = 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.SUITE_ID_REGEX = exports.TEST_ID_REGEX = void 0;
40
40
  exports.getPackageVersion = getPackageVersion;
41
+ exports.truncate = truncate;
41
42
  exports.cleanLatestRunId = cleanLatestRunId;
42
43
  exports.formatStep = formatStep;
43
44
  exports.readLatestRunId = readLatestRunId;
@@ -469,9 +470,17 @@ function transformEnvVarToBoolean(value) {
469
470
  // if not recognized, return truthy if any value is set
470
471
  return Boolean(value);
471
472
  }
473
+ function truncate(s, size = 255) {
474
+ if (s.toString().trim().length < size) {
475
+ return s.toString();
476
+ }
477
+ return `${s.toString().substring(0, size)}...`;
478
+ }
472
479
 
473
480
  module.exports.getPackageVersion = getPackageVersion;
474
481
 
482
+ module.exports.truncate = truncate;
483
+
475
484
  module.exports.cleanLatestRunId = cleanLatestRunId;
476
485
 
477
486
  module.exports.formatStep = formatStep;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "2.3.6-beta.2-fix-beforesuite",
3
+ "version": "2.3.6",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -2,7 +2,7 @@ import createDebugMessages from 'debug';
2
2
  import pc from 'picocolors';
3
3
  import TestomatClient from '../client.js';
4
4
  import { STATUS, APP_PREFIX, TESTOMAT_TMP_STORAGE_DIR } from '../constants.js';
5
- import { getTestomatIdFromTestTitle, fileSystem } from '../utils/utils.js';
5
+ import { getTestomatIdFromTestTitle, truncate, fileSystem } from '../utils/utils.js';
6
6
  import { services } from '../services/index.js';
7
7
  import { dataStorage } from '../data-storage.js';
8
8
  import codeceptjs from 'codeceptjs';
@@ -127,6 +127,28 @@ function CodeceptReporter(config) {
127
127
  });
128
128
 
129
129
 
130
+ // mark as failed all tests inside the failed hook
131
+ event.dispatcher.on(event.hook.failed, hook => {
132
+ if (hook.name !== 'BeforeSuiteHook') return;
133
+ const suite = hook.runnable.parent;
134
+
135
+ if (!suite) return;
136
+
137
+ const error = hook?.ctx?.currentTest?.err;
138
+
139
+ for (const test of suite.tests) {
140
+ client.addTestRun('failed', {
141
+ ...stripExampleFromTitle(test.title),
142
+ rid: test.uid,
143
+ test_id: getTestomatIdFromTestTitle(test.title),
144
+ suite_title: stripTagsFromTitle(suite.title),
145
+ error,
146
+ time: hook?.runnable?.duration,
147
+ });
148
+ }
149
+ });
150
+
151
+
130
152
  event.dispatcher.on(event.suite.before, suite => {
131
153
  dataStorage.setContext(suite.fullTitle());
132
154
  });
@@ -441,7 +463,7 @@ function formatCodeceptStep(step) {
441
463
  if (!step) return null;
442
464
 
443
465
  const category = step.constructor.name === 'HelperStep' ? 'framework' : 'user';
444
- const title = step.toString(); // Use built-in toString
466
+ const title = truncate(step); // Use built-in toString
445
467
  const duration = step.duration || 0; // Use built-in duration
446
468
 
447
469
  const formattedStep = {
@@ -469,10 +491,11 @@ function formatHookStep(step) {
469
491
  if (step.actor && step.name) {
470
492
  title = `${step.actor} ${step.name}`;
471
493
  if (step.args && step.args.length > 0) {
472
- const argsStr = step.args.map(arg => JSON.stringify(arg)).join(', ');
494
+ const argsStr = step.args.map(arg => truncate(JSON.stringify(arg))).join(', ');
473
495
  title += ` ${argsStr}`;
474
496
  }
475
497
  }
498
+ title = truncate(title);
476
499
 
477
500
  return {
478
501
  category: 'hook',
@@ -481,5 +504,6 @@ function formatHookStep(step) {
481
504
  };
482
505
  }
483
506
 
507
+
484
508
  export { CodeceptReporter };
485
509
  export default CodeceptReporter;
package/src/client.js CHANGED
@@ -10,7 +10,7 @@ import { glob } from 'glob';
10
10
  import path, { sep } from 'path';
11
11
  import { fileURLToPath } from 'node:url';
12
12
  import { S3Uploader } from './uploader.js';
13
- import { formatStep, readLatestRunId, storeRunId, validateSuiteId } from './utils/utils.js';
13
+ import { formatStep, truncate, readLatestRunId, storeRunId, validateSuiteId } from './utils/utils.js';
14
14
  import { filesize as prettyBytes } from 'filesize';
15
15
 
16
16
  const debug = createDebugMessages('@testomatio/reporter:client');
@@ -387,7 +387,7 @@ class Client {
387
387
  */
388
388
  formatLogs({ error, steps, logs }) {
389
389
  error = error?.trim();
390
- logs = logs?.trim();
390
+ logs = logs?.trim().split('\n').map(l => truncate(l)).join('\n');
391
391
 
392
392
  if (Array.isArray(steps)) {
393
393
  steps = steps
@@ -462,8 +462,6 @@ class TestomatioPipe {
462
462
  }
463
463
  });
464
464
 
465
- console.log(APP_PREFIX, '✅ Testrun finished');
466
-
467
465
  if (this.runUrl) {
468
466
  console.log(APP_PREFIX, '📊 Report Saved. Report URL:', pc.magenta(this.runUrl));
469
467
  }
@@ -428,8 +428,16 @@ function transformEnvVarToBoolean(value) {
428
428
  return Boolean(value);
429
429
  }
430
430
 
431
+ function truncate(s, size = 255) {
432
+ if (s.toString().trim().length < size) {
433
+ return s.toString();
434
+ }
435
+ return `${s.toString().substring(0, size)}...`;
436
+ }
437
+
431
438
  export {
432
439
  ansiRegExp,
440
+ truncate,
433
441
  cleanLatestRunId,
434
442
  isSameTest,
435
443
  fetchSourceCode,