@testomatio/reporter 0.7.0 → 0.7.2-beta.1

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/Changelog.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.7.2
2
+
3
+ * Fixed uploading non-existing file
4
+
5
+ # 0.7.1
6
+
7
+ * Support for NUnit XML v3 format
8
+
1
9
  # 0.7.0
2
10
 
3
11
  * Support for `@cucumber/cucumber` (>= 7.0) added
@@ -54,6 +54,11 @@ const uploadUsingS3 = async (filePath, runId) => {
54
54
  }
55
55
 
56
56
  const s3 = new AWS.S3(config);
57
+ if (!fs.existsSync(filePath)) {
58
+ console.error(chalk.yellow(`Artifacts file ${filePath} does not exist. Skipping...`));
59
+ return;
60
+ }
61
+
57
62
  const file = fs.readFileSync(filePath);
58
63
 
59
64
  Key = `${runId}/${randomUUID()}-${Key || path.basename(filePath)}`;
package/lib/xmlReader.js CHANGED
@@ -78,8 +78,9 @@ class XmlReader {
78
78
  } else if (jsonResult.testsuite) {
79
79
  jsonSuite = jsonResult;
80
80
  } else if (jsonResult.TestRun) {
81
-
82
- return this.processNUnit(jsonResult);
81
+ return this.processTRX(jsonResult);
82
+ } else if (jsonResult['test-run']) {
83
+ return this.processNUnit(jsonResult['test-run']);
83
84
  } else {
84
85
  console.log(jsonResult)
85
86
  throw new Error("Format can't be parsed")
@@ -112,6 +113,25 @@ class XmlReader {
112
113
  }
113
114
 
114
115
  processNUnit(jsonSuite) {
116
+ const { result, total, passed, failed, inconclusive, skipped } = jsonSuite;
117
+
118
+ reduceOptions.preferClassname = this.stats.language === 'python';
119
+ const resultTests = processTestSuite(jsonSuite['test-suite']);
120
+
121
+ this.tests = this.tests.concat(resultTests);
122
+
123
+ return {
124
+ status: result?.toLowerCase(),
125
+ create_tests: true,
126
+ tests_count: parseInt(total, 10),
127
+ passed_count: parseInt(passed, 10),
128
+ failed_count: parseInt(failed, 10),
129
+ skipped_count: parseInt(inconclusive + skipped, 10),
130
+ tests: resultTests,
131
+ };
132
+ }
133
+
134
+ processTRX(jsonSuite) {
115
135
  const tests = jsonSuite?.TestRun?.TestDefinitions?.UnitTest?.map(td => {
116
136
  const title = td.name.replace(/\(.*?\)/, '').trim();
117
137
  let example = td.name.match(/\((.*?)\)/);
@@ -374,6 +394,7 @@ module.exports = XmlReader;
374
394
 
375
395
  function reduceTestCases(prev, item) {
376
396
  let testCases = item.testcase;
397
+ if (!testCases) testCases = item['test-case'];
377
398
  if (!Array.isArray(testCases)) {
378
399
  testCases = [testCases]
379
400
  }
@@ -384,6 +405,7 @@ function reduceTestCases(prev, item) {
384
405
  let message = '';
385
406
  if (testCaseItem.error) stack = testCaseItem.error;
386
407
  if (testCaseItem.failure) stack = testCaseItem.failure;
408
+ if (testCaseItem?.failure?.['stack-trace']) stack = testCaseItem.failure['stack-trace'];
387
409
  if (testCaseItem?.failure?.message) message = testCaseItem.failure.message;
388
410
  if (testCaseItem?.error?.message) message = testCaseItem.error.message;
389
411
 
@@ -392,7 +414,7 @@ function reduceTestCases(prev, item) {
392
414
  if (!message) message = stack.trim().split('\n')[0];
393
415
 
394
416
  // prepend system output
395
- stack = `${testCaseItem['system-out'] || testCaseItem.log || ''}\n\n${stack}`.trim()
417
+ stack = `${testCaseItem['system-out'] || testCaseItem['output'] || testCaseItem.log || ''}\n\n${stack}`.trim()
396
418
 
397
419
  prev.push({
398
420
  create: true,
@@ -400,7 +422,7 @@ function reduceTestCases(prev, item) {
400
422
  stack,
401
423
  message,
402
424
  line: testCaseItem.lineno,
403
- run_time: testCaseItem.time,
425
+ run_time: testCaseItem.time || testCaseItem.duration,
404
426
  status: (testCaseItem.failure || testCaseItem.error) ? 'failed' : 'passed',
405
427
  title: testCaseItem.name,
406
428
  suite_title: reduceOptions.preferClassname ? testCaseItem.classname : (item.name || testCaseItem.classname),
@@ -412,6 +434,7 @@ function reduceTestCases(prev, item) {
412
434
  function processTestSuite(testsuite) {
413
435
  if (!testsuite) return [];
414
436
  if (testsuite.testsuite) return processTestSuite(testsuite.testsuite)
437
+ if (testsuite['test-suite']) return processTestSuite(testsuite['test-suite'])
415
438
 
416
439
  let suites = testsuite;
417
440
  if (!Array.isArray(testsuite)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "0.7.0",
3
+ "version": "0.7.2-beta.1",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "repository": "git@github.com:testomatio/reporter.git",
@@ -24,7 +24,7 @@
24
24
  "bin",
25
25
  "lib",
26
26
  "testcafe"
27
- ],
27
+ ],
28
28
  "scripts": {
29
29
  "pretty": "prettier --write .",
30
30
  "lint": "eslint lib",