diff --git a/package-lock.json b/package-lock.json index 8c0a4387..cf18ff92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23616,9 +23616,9 @@ } }, "node_modules/junit-report-builder": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/junit-report-builder/-/junit-report-builder-3.0.1.tgz", - "integrity": "sha512-B8AZ2q24iGwPM3j/ZHc9nD0BY1rKhcnWCA1UvT8mhHfR8Vo/HTtg3ojMyo55BgctqQGZG7H8z0+g+mEUc32jgg==", + "version": "3.2.1", + "resolved": "https://tablecheck-934763610305.d.codeartifact.ap-northeast-1.amazonaws.com/npm/tablecheck/junit-report-builder/-/junit-report-builder-3.2.1.tgz", + "integrity": "sha512-IMCp5XyDQ4YESDE4Za7im3buM0/7cMnRfe17k2X8B05FnUl9vqnaliX6cgOEmPIeWKfJrEe/gANRq/XgqttCqQ==", "dependencies": { "date-format": "4.0.3", "lodash": "^4.17.21", @@ -37551,7 +37551,7 @@ "license": "MIT", "dependencies": { "@commitlint/config-conventional": "^17", - "junit-report-builder": "3.0.1" + "junit-report-builder": "3.2.1" }, "engines": { "node": ">= 16.16.0" diff --git a/packages/commitlint-config/formatters/junit.js b/packages/commitlint-config/formatters/junit.js index 32321e8d..69fb95ca 100644 --- a/packages/commitlint-config/formatters/junit.js +++ b/packages/commitlint-config/formatters/junit.js @@ -5,6 +5,12 @@ const builder = require('junit-report-builder'); +const levelMap = { + [0]: 'Disabled', + [1]: 'Warning', + [2]: 'Error', +}; + /** * Format the commitlint report as a valid JUnit XML report. * @@ -19,19 +25,21 @@ function formatJunit(report = {}) { const errorCount = result.errors?.length || 0; const warningCount = result.warnings?.length || 0; const suite = builder.testSuite().name(result.input); - suite.property('errors', errorCount); - suite.property('failures', errorCount + warningCount); - suite.property('tests', Math.max(errorCount + warningCount, 1)); - suite.property('skipped', 0); result.errors?.forEach((error) => { - const testcase = suite.testCase().className('error').name(error.name); - testcase.failure('error').standardOutput(error.message); + suite + .testCase() + .name(error.name) + .className(levelMap[error.level]) + .error(error.message); }); result.warnings?.forEach((warning) => { - const testcase = suite.testCase().className('warning').name(warning.name); - testcase.failure('warning').standardOutput(warning.message); + suite + .testCase() + .name(warning.name) + .className(levelMap[warning.level]) + .failure(warning.message); }); if (errorCount + warningCount === 0) { @@ -39,7 +47,7 @@ function formatJunit(report = {}) { } }); - return builder.build(); + return builder.name('Commit Lint').build(); } module.exports = formatJunit; diff --git a/packages/commitlint-config/package.json b/packages/commitlint-config/package.json index 52f34e9b..4ac9325f 100644 --- a/packages/commitlint-config/package.json +++ b/packages/commitlint-config/package.json @@ -16,7 +16,7 @@ "files": ["formatters"], "dependencies": { "@commitlint/config-conventional": "^17", - "junit-report-builder": "3.0.1" + "junit-report-builder": "3.2.1" }, "peerDependencies": { "@commitlint/cli": "^17"