
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
jest-sonar-reporter
Advanced tools
jest-sonar-reporter is a custom results processor for Jest. The processor converts Jest's output into Sonar's generic test data format.
Using npm:
$ npm i -D jest-sonar-reporter
Using yarn:
$ yarn add -D jest-sonar-reporter
Configure Jest in your package.json to use jest-sonar-reporter as a custom results processor.
{
"jest": {
"testResultsProcessor": "jest-sonar-reporter"
}
}
Configure Sonar to import the test results. Add the sonar.testExecutionReportPaths property to your
sonar-project.properties file.
sonar.testExecutionReportPaths=test-report.xml
To customize the reporter you can use package.json to store the configuration.
Create a jestSonar entry like this:
{
"jestSonar": {}
}
You can customize the following options:
reportPath This will specify the path to put the report in.reportFile This will specify the file name of the report.indent This will specify the indentation to format the report.{
"jestSonar": {
"reportPath": "reports",
"reportFile": "test-reporter.xml",
"indent": 4
}
}
Important: Don't forget to update
sonar.testExecutionReportPathswhen you use a custom path and file name.
Sonarqube 5.6.x does not support Generic Test Data however it has a Generic Test Coverage plugin which offers similar functionality.
If you have the plugin installed on Sonarqube, you can configure this reporter to produce files in supported format.
{
"jestSonar": {
"sonar56x": true
}
}
Configure Sonar to import the test results. Add the sonar.genericcoverage.unitTestReportPaths property to your
sonar-project.properties file.
sonar.genericcoverage.unitTestReportPaths=test-report.xml
To support different environments add the env property to the configuration and overwrite the value of the option you want to modify for the specific environment.
You can overwrite the following configuration options: reportPath, reportFile, indent, sonar56x
For example: Overwrite the path were the report will be stored.
{
"jestSonar": {
"reportPath": "reports",
"reportFile": "test-reporter.xml",
"indent": 4,
"env": {
"test": {
"reportPath": "reports-test"
}
}
}
}
Use the NODE_ENV variable to activate the environment specific configuration.
NODE_ENV=test npm run test
Using npm:
$ npm run test
Using yarn:
$ yarn run test
$ sonar-scanner
This project uses the MIT licence.
jest-junit is a popular Jest reporter that outputs test results in JUnit XML format, which is widely used for CI/CD pipelines and can be integrated with various tools, including SonarQube. While jest-junit focuses on JUnit XML format, jest-sonar-reporter specifically targets SonarQube's requirements, making it more specialized for SonarQube integration.
jest-html-reporter generates HTML reports from Jest test results. It provides a visually appealing way to view test results, but it does not directly support SonarQube integration. In contrast, jest-sonar-reporter is designed to produce reports specifically for SonarQube, focusing on XML output rather than HTML.
FAQs
A Sonar test reporter for Jest.
The npm package jest-sonar-reporter receives a total of 412,951 weekly downloads. As such, jest-sonar-reporter popularity was classified as popular.
We found that jest-sonar-reporter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.