From 3efab36f56d2c746e3f373587c17decef8f5165a Mon Sep 17 00:00:00 2001 From: agracio Date: Sat, 30 Nov 2024 19:30:49 +0000 Subject: [PATCH] updating code --- README.md | 2 ++ jest.config.js | 9 ++++++ package-lock.json | 71 ++++++++++++++++++++++++++++++++++++++++++++++- package.json | 3 +- src/junit.js | 3 +- 5 files changed, 84 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1d63b30..37856b3 100644 --- a/README.md +++ b/README.md @@ -111,12 +111,14 @@ convert(options).then(() => console.log(`Report created: ${options.reportDir}/${ | `html` | boolean | false | Create Mochawesome HTML? | | `htmlReportFilename` | string | mochawesome.html | Mochawesome HTML file name | | `skippedAsPending` | boolean | true | Show skipped tests as pending in HTML | +| `switchClassnameAndName` | boolean | false | Switch test case classname and name | - `testFile` - relative or absolute path to input test file. - `testType` - type of test report, not case-sensitive. - `reportDir` - will be created if path does not exist. - `skippedAsPending` - Mocha always reports skipped tests as pending and this is default behaviour of converter. Set to `false` to display tests as skipped. +- `switchClassnameAndName` - Switches classname and name attributes of testcase in case your test naming data is generated in reverse order. #### Supported `testType` options. diff --git a/jest.config.js b/jest.config.js index 6f172a6..c58af32 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,5 +4,14 @@ module.exports = { reporters: [ 'default', 'github-actions', + ["jest-html-reporters", { + publicPath: './tests/report', + filename: 'report.html', + darkTheme: true, + pageTitle: 'mochawesome-converter', + expand: true, + urlForTestFiles: 'https://github.com/agracio/mochawesome-converter/blob/main' + } + ] ], } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c40fb80..7d2c430 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,8 @@ "xslt-processor": "^3.3.1" }, "devDependencies": { - "jest": "^29.7.0" + "jest": "^29.7.0", + "jest-html-reporters": "^3.1.7" }, "engines": { "node": ">= 18" @@ -1598,6 +1599,16 @@ "node": ">=0.10.0" } }, + "node_modules/define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -2045,6 +2056,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -2087,6 +2114,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -2432,6 +2472,17 @@ "fsevents": "^2.3.2" } }, + "node_modules/jest-html-reporters": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/jest-html-reporters/-/jest-html-reporters-3.1.7.tgz", + "integrity": "sha512-GTmjqK6muQ0S0Mnksf9QkL9X9z2FGIpNSxC52E0PHDzjPQ1XDu2+XTI3B3FS43ZiUzD1f354/5FfwbNIBzT7ew==", + "dev": true, + "license": "MIT", + "dependencies": { + "fs-extra": "^10.0.0", + "open": "^8.0.3" + } + }, "node_modules/jest-leak-detector": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz", @@ -3141,6 +3192,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/open": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", + "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/opener": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz", diff --git a/package.json b/package.json index 2aab5a4..a3d9299 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "xslt-processor": "^3.3.1" }, "devDependencies": { - "jest": "^29.7.0" + "jest": "^29.7.0", + "jest-html-reporters": "^3.1.7" } } diff --git a/src/junit.js b/src/junit.js index 94287b1..c64fc94 100644 --- a/src/junit.js +++ b/src/junit.js @@ -1,7 +1,7 @@ const fs = require('fs'); const path = require('path'); -const parser = require('p3x-xml2json'); const crypto = require("crypto"); +const parser = require('p3x-xml2json'); const marge = require('mochawesome-report-generator'); const xmlFormat = require('xml-formatter'); const _ = require('lodash'); @@ -126,7 +126,6 @@ function parseXml(options, xml){ if(options.testType === 'trx' && json.testsuites[0].testsuite[0].testcase.length !== 0){ json = parseTrx(options, json); } - //console.log(_.sumBy(json.testsuites[0].testsuite, function(suite) { return Number(suite.tests); })); return json.testsuites[0]; }