Gathering detailed insights and metrics for @casualbot/jest-sonar-reporter
Gathering detailed insights and metrics for @casualbot/jest-sonar-reporter
Gathering detailed insights and metrics for @casualbot/jest-sonar-reporter
Gathering detailed insights and metrics for @casualbot/jest-sonar-reporter
npm install @casualbot/jest-sonar-reporter
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
9 Stars
114 Commits
4 Forks
1 Watching
4 Branches
1 Contributors
Updated on 12 Sept 2024
TypeScript (92.67%)
JavaScript (7.33%)
Cumulative downloads
Total Downloads
Last day
28.7%
6,367
Compared to previous day
Last week
13.7%
30,150
Compared to previous week
Last month
-16.7%
116,149
Compared to previous month
Last year
60.1%
1,365,223
Compared to previous year
27
@casualbot/jest-sonar-reporter
is a custom results processor for Jest derived from Christian W. original work here.
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.
Using npm:
1npm install --save-dev @casualbot/jest-sonar-reporter
Using yarn:
1yarn add --dev @casualbot/jest-sonar-reporter
In your jest config add the following entry:
1{ 2 "reporters": [ "default", "@casualbot/jest-sonar-reporter" ] 3}
Then simply run:
1jest
For your Continuous Integration you can simply do:
1jest --ci --reporters=default --reporters=@casualbot/jest-sonar-reporter
The support for testResultsProcessor
is only kept for [legacy reasons][test-results-processor] and might be removed in the future.
You should therefore prefer to configure @casualbot/jest-sonar-reporter
as a reporter.
Should you still want to, add the following entry to your jest config:
1{ 2 "testResultsProcessor": "@casualbot/jest-sonar-reporter" 3}
Then simply run:
1jest
For your Continuous Integration you can simply do:
1jest --ci --testResultsProcessor="@casualbot/jest-sonar-reporter"
@casualbot/jest-sonar-reporter
offers several configurations based on environment variables or a @casualbot/jest-sonar-reporter
key defined in package.json
or a reporter option.
Environment variable and package.json configuration should be strings.
Reporter options should also be strings exception for suiteNameTemplate, classNameTemplate, titleNameTemplate that can also accept a function returning a string.
Environment Variable Name | Reporter Config Name | Description | Default | Possible Injection Values |
---|---|---|---|---|
JEST_SUITE_NAME | suiteName | name attribute of <testsuites> | "jest tests" | N/A |
JEST_SONAR_OUTPUT_DIR | outputDirectory | Directory to save the output. | process.cwd() | N/A |
JEST_SONAR_OUTPUT_NAME | outputName | File name for the output. | "jest-report.xml" | N/A |
JEST_SONAR_OUTPUT_FILE | outputFile | Fullpath for the output. If defined, outputDirectory and outputName will be overridden | undefined | N/A |
JEST_SONAR_56_FORMAT | formatForSonar56 | Will generate the xml report for Sonar 5.6 | false | N/A |
JEST_SONAR_RELATIVE_PATHS | relativePaths | Will use relative paths when generating the xml report | false | N/A |
JEST_SONAR_UNIQUE_OUTPUT_NAME | uniqueOutputName | Create unique file name for the output jest-sonar-report-${uuid}.xml , overrides outputName | false | N/A |
JEST_SONAR_SUITE_NAME | suiteNameTemplate | Template string for name attribute of the <testsuite> . | "{title}" | {title} , {filepath} , {filename} , {displayName} |
JEST_SONAR_CLASSNAME | classNameTemplate | Template string for the classname attribute of <testcase> . | "{classname} {title}" | {classname} , {title} , {suitename} , {filepath} , {filename} , {displayName} |
JEST_SONAR_TITLE | titleTemplate | Template string for the name attribute of <testcase> . | "{classname} {title}" | {classname} , {title} , {filepath} , {filename} , {displayName} |
JEST_SONAR_ANCESTOR_SEPARATOR | ancestorSeparator | Character(s) used to join the describe blocks. | " " | N/A |
JEST_SONAR_ADD_FILE_ATTRIBUTE | addFileAttribute | Add file attribute to the output. This config is primarily for Circle CI. This setting provides richer details but may break on other CI platforms. Must be a string. | "false" | N/A |
JEST_SONAR_INCLUDE_CONSOLE_OUTPUT | includeConsoleOutput | Adds console output to any testSuite that generates stdout during a test run. | false | N/A |
JEST_SONAR_INCLUDE_SHORT_CONSOLE_OUTPUT | includeShortConsoleOutput | Adds short console output (only message value) to any testSuite that generates stdout during a test run. | false | N/A |
JEST_SONAR_REPORT_TEST_SUITE_ERRORS | reportTestSuiteErrors | Reports test suites that failed to execute altogether as error . Note: since the suite name cannot be determined from files that fail to load, it will default to file path. | false | N/A |
JEST_SONAR_NO_STACK_TRACE | noStackTrace | Omit stack traces from test failure reports, similar to jest --noStackTrace | false | N/A |
JEST_USE_PATH_FOR_SUITE_NAME | usePathForSuiteName | DEPRECATED. Use suiteNameTemplate instead. Use file path as the name attribute of <testsuite> | "false" | N/A |
You can configure these options via the command line as seen below:
1JEST_SUITE_NAME="Jest JUnit Unit Tests" JEST_SONAR_OUTPUT_DIR="./artifacts" jest
Or you can also define a @casualbot/jest-sonar-reporter
key in your package.json
. All are string values.
1{ 2 ..., 3 "jest": { 4 "rootDir": ".", 5 "testResultsProcessor": "@casualbot/jest-sonar-reporter" 6 }, 7 "@casualbot/jest-sonar-reporter": { 8 "suiteName": "jest tests", 9 "outputDirectory": "coverage", 10 "outputName": "jest-report.xml", 11 "uniqueOutputName": "false", 12 "classNameTemplate": "{classname}-{title}", 13 "titleTemplate": "{classname}-{title}", 14 "ancestorSeparator": " › ", 15 "usePathForSuiteName": "true", 16 "relativePaths": "true" 17 } 18}
Or you can define your options in your reporter configuration.
1// jest.config.js 2{ 3 reporters: [ 4 'default', 5 [ 6 '@casualbot/jest-sonar-reporter', 7 { 8 relativePaths: true, 9 outputName: 'sonar-report.xml', 10 outputDirectory: 'coverage' 11 } 12 ] 13 ], 14}
No vulnerabilities found.
No security vulnerabilities found.