Registry / testing / node-reporter-sonarqube

node-reporter-sonarqube

JSON →
library1.0.3jsnpmunverified

The `node-reporter-sonarqube` package provides a specialized test reporter designed for the native Node.js Test Runner, enabling seamless integration with SonarQube and SonarCloud platforms. It processes the output from Node's built-in test runner and generates a standard 'Generic Test Data' XML report (typically `test-report.xml`), which can then be consumed by SonarQube/SonarCloud for code quality analysis and metric tracking. Currently stable at version `1.0.3`, the project maintains a focused release cadence, primarily issuing updates for dependency management and minor fixes, rather than frequent new features. Its key differentiator is its direct compatibility with `node --test` command-line arguments, making it a straightforward solution for JavaScript and TypeScript projects that utilize the native Node.js testing framework and require SonarQube/SonarCloud integration for test execution reporting.

npm install node-reporter-sonarqube
INSTALL
IMPORT
SIG · NODE-REPORTER-SONA
N
node-reporter-sonarqube
testingjavascriptv1.0.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Reporter instantiation (incorrect)
✓ This package is not imported into JavaScript/TypeScript code. It is used exclusively via Node.js CLI arguments.
✗ import SonarQubeReporter from 'node-reporter-sonarqube'; const reporter = new SonarQubeReporter();
The `node-reporter-sonarqube` package functions as a command-line test reporter for the Node.js Test Runner. It does not export any JavaScript classes, functions, or objects for direct programmatic import or instantiation within your application or test files.
Named import (incorrect)
✓ Utilize `node --test --test-reporter=node-reporter-sonarqube` directly from your shell or npm script.
✗ import { createSonarQubeReporter } from 'node-reporter-sonarqube';
Developers should not attempt to import specific utilities or constructors from this package. Its integration point is solely through the `--test-reporter` flag of the Node.js `test` command, which handles its lifecycle internally.
CommonJS require (incorrect)
✓ Ensure `node-reporter-sonarqube` is installed as a `devDependency` and configured via `package.json` scripts or direct CLI calls.
✗ const sonarqube = require('node-reporter-sonarqube');
Similar to ES module imports, CommonJS `require()` is not applicable for interacting with this package. Its functionality is invoked by the Node.js runtime when specified as a test reporter, not by direct module loading.

Demonstrates installation and basic command-line usage to generate a SonarQube compatible test report using the Node.js Test Runner.

npm install --save-dev node-reporter-sonarqube # Configure your package.json scripts for convenience # For example, in your package.json: // "scripts": { // "test:sonarqube": "node --test --test-reporter=node-reporter-sonarqube --test-reporter-destination=test-report.xml" // } # Run your Node.js tests and generate the SonarQube report node --test --test-reporter=spec --test-reporter-destination=stdout \ --test-reporter=node-reporter-sonarqube --test-reporter-destination=test-report.xml # This will output standard test results to stdout and a SonarQube-compatible XML to test-report.xml # You would then typically upload test-report.xml during a SonarQube/SonarCloud scan.
Debug
Known issues
gotchaWhen running multiple reporters, ensure each `--test-reporter` has its own `--test-reporter-destination`. Incorrect pairing can lead to reports being overwritten or going to `stdout` unintentionally.
fix
Always specify `--test-reporter-destination` immediately after its corresponding `--test-reporter`, e.g., `node --test --test-reporter=spec --test-reporter-destination=stdout --test-reporter=node-reporter-sonarqube --test-reporter-destination=test-report.xml`.
affects: >=1.0.0
gotchaFor SonarCloud/SonarQube scans, verify that the `sonar.testExecutionReportPaths` property is correctly configured in your `sonar-project.properties` or scan arguments to point to the generated XML report (e.g., `test-report.xml`).
fix
In your SonarCloud GitHub Action or Sonar Scanner CLI, ensure `-Dsonar.testExecutionReportPaths=path/to/test-report.xml` is present and accurate.
affects: >=1.0.0
gotchaPrior to v1.0.1, there was an issue where generated paths in the XML report might not always be relative, potentially causing issues with SonarQube path resolution in some environments.
fix
Update to `node-reporter-sonarqube` v1.0.1 or later to ensure relative paths are correctly generated in the `test-report.xml`.
affects: <1.0.1
Errors
Common errors & fixes
Error: Reporter 'node-reporter-sonarqube' not found
The package is not installed or Node.js cannot resolve its path.
fix
Ensure `node-reporter-sonarqube` is installed as a development dependency (`npm install --save-dev node-reporter-sonarqube`) and that Node.js is run in an environment where `node_modules` is accessible.
Failed to read test execution report: file 'test-report.xml' not found
The SonarQube/SonarCloud scanner could not find the `test-report.xml` file at the specified path.
fix
Verify that your Node.js test command successfully generated `test-report.xml` and that the `sonar.testExecutionReportPaths` property in your SonarQube/SonarCloud configuration points to the correct location and filename.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
node-reporter-sonarqube — npm install node-reporter-sonarqube · libregistry