@testomatio/reporter 1.4.2-beta-specflow-compat.2 → 1.4.3

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.
@@ -44,15 +44,10 @@ program
44
44
 
45
45
  let timeoutTimer;
46
46
  if (opts.timelimit) {
47
- timeoutTimer = setTimeout(
48
- () => {
49
- console.log(
50
- `⚠️ Reached timeout of ${opts.timelimit}s. Exiting... (Exit code is 0 to not fail the pipeline)`,
51
- );
52
- process.exit(0);
53
- },
54
- parseInt(opts.timelimit, 10) * 1000,
55
- );
47
+ timeoutTimer = setTimeout(() => {
48
+ console.log(`⚠️ Reached timeout of ${opts.timelimit}s. Exiting... (Exit code is 0 to not fail the pipeline)`);
49
+ process.exit(0);
50
+ }, parseInt(opts.timelimit, 10) * 1000);
56
51
  }
57
52
 
58
53
  try {
@@ -103,9 +103,9 @@ const uploadUsingS3 = async (filePath, runId) => {
103
103
  let Key;
104
104
 
105
105
  if (typeof filePath === 'object') {
106
- ContentType = filePath.type;
107
- filePath = filePath.path;
108
- Key = filePath.name;
106
+ ContentType = filePath?.type;
107
+ filePath = filePath?.path;
108
+ Key = filePath?.name;
109
109
  }
110
110
 
111
111
  const { TESTOMATIO_PRIVATE_ARTIFACTS, S3_BUCKET } = getConfig();
@@ -11,7 +11,6 @@ class CSharpAdapter extends Adapter {
11
11
  t.title = title.trim();
12
12
  return t;
13
13
  }
14
-
15
14
  }
16
15
 
17
16
  module.exports = CSharpAdapter;
@@ -79,13 +79,13 @@ class GitLabPipe {
79
79
  let summary = `${this.hiddenCommentData}
80
80
 
81
81
  | [![Testomat.io Report](${testomatLogoURL})](https://testomat.io) | ${statusEmoji(
82
- runParams.status,
83
- )} ${runParams.status.toUpperCase()} ${statusEmoji(runParams.status)} |
82
+ runParams.status,
83
+ )} ${runParams.status.toUpperCase()} ${statusEmoji(runParams.status)} |
84
84
  | --- | --- |
85
85
  | Tests | ✔️ **${this.tests.length}** tests run |
86
86
  | Summary | ${statusEmoji('failed')} **${failedCount}** failed; ${statusEmoji(
87
- 'passed',
88
- )} **${passedCount}** passed; **${statusEmoji('skipped')}** ${skippedCount} skipped |
87
+ 'passed',
88
+ )} **${passedCount}** passed; **${statusEmoji('skipped')}** ${skippedCount} skipped |
89
89
  | Duration | 🕐 **${humanizeDuration(
90
90
  parseInt(
91
91
  this.tests.reduce((a, t) => a + (t.run_time || 0), 0),
@@ -246,7 +246,9 @@ const foundedTestLog = (app, tests) => {
246
246
  };
247
247
 
248
248
  const humanize = text => {
249
- text = decamelize(text);
249
+ // if there are no spaces, decamelize
250
+ if (!text.trim().includes(' ')) text = decamelize(text);
251
+
250
252
  return text
251
253
  .replace(/_./g, match => ` ${match.charAt(1).toUpperCase()}`)
252
254
  .trim()
package/lib/xmlReader.js CHANGED
@@ -69,7 +69,19 @@ class XmlReader {
69
69
  }
70
70
 
71
71
  parse(fileName) {
72
- const xmlData = fs.readFileSync(path.resolve(fileName));
72
+ let xmlData = fs.readFileSync(path.resolve(fileName)).toString();
73
+
74
+ // we remove too long stack traces
75
+ const cutRegexes = [
76
+ /(<output><!\[CDATA\[)([\s\S]*?)(\]\]><\/output>)/g,
77
+ /(<system-err><!\[CDATA\[)([\s\S]*?)(\]\]><\/system-err>)/g,
78
+ /(<system-out><!\[CDATA\[)([\s\S]*?)(\]\]><\/system-out>)/g,
79
+ ];
80
+
81
+ for (const regex of cutRegexes) {
82
+ xmlData = xmlData.replace(regex, (_, p1, p2, p3) => `${p1}${p2.substring(0, 5000)}${p3}`);
83
+ }
84
+
73
85
  const jsonResult = this.parser.parse(xmlData);
74
86
  let jsonSuite;
75
87
 
@@ -422,6 +434,10 @@ function reduceTestCases(prev, item) {
422
434
  if (!Array.isArray(testCases)) {
423
435
  testCases = [testCases];
424
436
  }
437
+
438
+ // suite inside test case
439
+ if (item['test-suite'] && item['test-suite']['test-case']) testCases.push(...item['test-suite']['test-case']);
440
+
425
441
  const suiteOutput = item['system-out'] || item.output || item.log || '';
426
442
  const suiteErr = item['system-err'] || item.output || item.log || '';
427
443
  testCases
@@ -429,7 +445,6 @@ function reduceTestCases(prev, item) {
429
445
  .forEach(testCaseItem => {
430
446
  const file = testCaseItem.file || item.filepath || '';
431
447
 
432
-
433
448
  let stack = '';
434
449
  let message = '';
435
450
  if (testCaseItem.error) stack = testCaseItem.error;
@@ -444,12 +459,16 @@ function reduceTestCases(prev, item) {
444
459
 
445
460
  // SpecFlow config
446
461
  let { title, tags } = fetchProperties(item.type === 'ParameterizedMethod' ? item : testCaseItem);
462
+ let example = null;
447
463
 
448
464
  title ||= testCaseItem.name || testCaseItem.methodname || testCaseItem.classname;
449
465
  tags ||= [];
450
466
 
451
- let example = testCaseItem.name.match(/\((.*?)\)/);
452
- if (example) example = { ...example[1].split(',') };
467
+ const exampleMatches = title.match(/\((.*?)\)/);
468
+ if (exampleMatches) {
469
+ example = { ...exampleMatches[1].split(',').map(v => v.replace(/^['"]|['"]$/g, '')) };
470
+ title = title.replace(/\(.*?\)/, '').trim();
471
+ }
453
472
 
454
473
  // eslint-disable-next-line
455
474
  stack = `${
@@ -484,26 +503,28 @@ function processTestSuite(testsuite) {
484
503
  if (!testsuite) return [];
485
504
  if (testsuite.testsuite) return processTestSuite(testsuite.testsuite);
486
505
  if (testsuite['test-suite'] && !testsuite['test-case']) return processTestSuite(testsuite['test-suite']);
487
-
506
+
488
507
  let suites = testsuite;
489
508
  if (!Array.isArray(testsuite)) {
490
509
  suites = [testsuite];
491
510
  }
492
- if (testsuite['test-suite']) suites.push(testsuite['test-suite']);
493
511
 
494
512
  const res = suites.flat().reduce(reduceTestCases, []);
495
-
513
+
496
514
  return res;
497
515
  }
498
516
 
499
517
  function fetchProperties(item) {
500
- let tags = [];
518
+ const tags = [];
501
519
  let title = '';
502
520
 
503
521
  if (!item.properties) return {};
504
522
 
505
523
  const prop = [item.properties?.property].flat().find(p => p.name === 'Description');
506
524
  if (prop) title = prop.value;
507
- [item.properties?.property].flat().filter(p => p.name === 'Category').forEach(p => tags.push(p.value));
508
- return { title, tags }
509
- }
525
+ [item.properties?.property]
526
+ .flat()
527
+ .filter(p => p.name === 'Category')
528
+ .forEach(p => tags.push(p.value));
529
+ return { title, tags };
530
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "1.4.2-beta-specflow-compat.2",
3
+ "version": "1.4.3",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "typings": "typings/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  ],
42
42
  "scripts": {
43
43
  "clear-exportdir": "rm -rf export/",
44
- "pretty": "npx prettier --debug-check --check .",
44
+ "pretty": "npx prettier --check .",
45
45
  "pretty:fix": "prettier --write .",
46
46
  "lint": "eslint lib",
47
47
  "lint:fix": "eslint lib --fix",