karma-sonarqube-reporter is a Karma reporter plugin designed to generate generic test execution reports compatible with SonarQube. The current stable version is 1.4.0. It aims to bridge the gap between JavaScript/TypeScript unit test results run by Karma and the SonarQube analysis platform, enabling projects to integrate test coverage and outcomes directly into their SonarQube quality gate processes. Releases are primarily driven by bug fixes, dependency updates, and minor feature enhancements, with a new feature release (1.3.0) and dynamic test support (1.4.0) indicating ongoing, albeit not rapid, development. A key differentiator is its `legacyMode` option, which allows it to support both modern and older SonarQube versions, providing flexibility for diverse project environments. It focuses solely on test reporting for SonarQube, making it a specialized tool for this specific integration.
npm install karma-sonarqube-reporterVerified import paths — ran on the pinned version, not inferred.
This configuration demonstrates how to set up `karma-sonarqube-reporter` in a `karma.conf.js` file, loading it as a plugin, activating it, and configuring its options to generate SonarQube compatible XML reports.
Ensure `legacyMode` is set to `true` if your SonarQube instance is older than version 6.2. For SonarQube 6.2 and newer, set `legacyMode` to `false`.
Verify that your `sonar-project.properties` file contains the correct property for your `legacyMode` setting and that the path (or comma-delimited list of paths) accurately reflects the `outputFolder` configured in `karma.conf.js`.
Upgrade your Node.js environment to version 8.10.0 or higher to ensure compatibility and stability with the reporter plugin.
Run `npm install karma-sonarqube-reporter --save-dev` to install the package.
Ensure `sonarqubeReporter: { ... }` is correctly defined in your `karma.conf.js` with all required properties, even if using default values.Adjust `basePath` and `filePattern` to accurately reflect the location and naming convention of your unit test files (e.g., `**/*spec.ts` for Angular projects) and ensure Karma is configured to run those tests.