jest-to-sonar is a utility library designed to convert Jest test results into the SonarQube Generic Test Execution Report format (XML). This enables developers to integrate JavaScript and TypeScript project test coverage and execution results directly into SonarQube for quality analysis. The current stable version is 1.3.0. Releases are made on an as-needed basis to address bug fixes and new features, such as supporting custom output paths introduced in v1.1.0 and fixing report data format in v1.3.0. Its primary differentiator is its seamless integration as a Jest reporter, simplifying the setup for SonarQube analysis within CI/CD pipelines without requiring manual conversion scripts.
npm install jest-to-sonarVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `jest-to-sonar` in a `jest.config.js` file, define a basic test, and generate a SonarQube generic test execution report after running tests.
Upgrade to `jest-to-sonar@^1.3.0` or newer: `npm install jest-to-sonar@latest` or `yarn add jest-to-sonar@latest`.
In `jest.config.js`, set `collectCoverage: true` and define `coverageDirectory: './coverage'`. Then configure `outputFile: './coverage/sonar-report.xml'` (or your preferred path within `coverageDirectory`) in the `jest-to-sonar` reporter options.
Ensure `jest-to-sonar` is installed as a dev dependency: `npm install --save-dev jest-to-sonar` or `yarn add --dev jest-to-sonar`.
First, ensure you are using `jest-to-sonar@^1.3.0` or newer to avoid known formatting issues. Verify the `sonar-report.xml` file is generated and check its content for obvious syntax errors. Also, review your Jest tests for any non-standard outputs that might interfere with the reporter's parsing.
No dependency data recorded yet.