@casualbot/jest-sonar-reporter
Advanced tools
Comparing version 2.3.1 to 2.4.0
@@ -20,2 +20,3 @@ declare const _default: { | ||
JEST_SONAR_RELATIVE_PATHS: string; | ||
JEST_SONAR_PROJECT_ROOT: string; | ||
JEST_SONAR_56_FORMAT: string; | ||
@@ -40,2 +41,3 @@ }; | ||
relativePaths: boolean; | ||
projectRoot: any; | ||
formatForSonar56: boolean; | ||
@@ -42,0 +44,0 @@ }; |
@@ -22,2 +22,3 @@ "use strict"; | ||
JEST_SONAR_RELATIVE_PATHS: 'relativePaths', | ||
JEST_SONAR_PROJECT_ROOT: 'projectRoot', | ||
JEST_SONAR_56_FORMAT: 'formatForSonar56' | ||
@@ -42,2 +43,3 @@ }, | ||
relativePaths: false, | ||
projectRoot: null, | ||
formatForSonar56: false | ||
@@ -44,0 +46,0 @@ }, |
@@ -9,3 +9,3 @@ "use strict"; | ||
const aTestExecution = [{ _attr: { version: '1' } }]; | ||
const testResults = data.testResults.map((result) => { return (0, file_1.default)(result, options.relativePaths); }); | ||
const testResults = data.testResults.map((result) => { return (0, file_1.default)(result, options.relativePaths, options.projectRoot); }); | ||
return options?.formatForSonar56 | ||
@@ -12,0 +12,0 @@ ? { unitTest: aTestExecution.concat(testResults) } |
@@ -1,2 +0,2 @@ | ||
declare const _default: (testResult: any, relativePaths?: boolean) => any; | ||
declare const _default: (testResult: any, relativePaths: boolean, projectRoot: string | null) => any; | ||
export default _default; |
@@ -24,6 +24,7 @@ "use strict"; | ||
const path = __importStar(require("path")); | ||
exports.default = (testResult, relativePaths = false) => { | ||
exports.default = (testResult, relativePaths = false, projectRoot) => { | ||
let aFile; | ||
if (relativePaths) { | ||
aFile = [{ _attr: { path: path.relative(process.cwd(), testResult.testFilePath) } }]; | ||
const relativeRoot = projectRoot == null ? process.cwd() : path.resolve(projectRoot); | ||
aFile = [{ _attr: { path: path.relative(relativeRoot, testResult.testFilePath) } }]; | ||
} | ||
@@ -30,0 +31,0 @@ else { |
{ | ||
"name": "@casualbot/jest-sonar-reporter", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"description": "A Sonar test reporter for Jest.", | ||
@@ -19,2 +19,3 @@ "keywords": [ | ||
"main": "lib/index.js", | ||
"files": [ "lib", "lib/src" ], | ||
"scripts": { | ||
@@ -21,0 +22,0 @@ "test": "tsc --module commonjs && jest", |
@@ -6,3 +6,3 @@ # Jest Sonar Reporter | ||
`@casualbot/jest-sonar-scanner` is a custom results processor for Jest derived from Christian W. original work [here](https://github.com/3dmind/jest-sonar-reporter). | ||
`@casualbot/jest-sonar-reporter` is a custom results processor for Jest derived from Christian W. original work [here](https://github.com/3dmind/jest-sonar-reporter). | ||
@@ -9,0 +9,0 @@ It has been updated to be usable as a reporter in the `jest.config`, as well as, provide the ability to output relative paths for the generated XML file. |
Sorry, the diff of this file is not supported yet
36320
23
615