{"id":13656,"library":"node-reporter-sonarqube","title":"SonarQube Test Reporter for Node.js Test Runner","description":"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.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/sjinks/node-reporter-sonarqube","tags":["javascript","test-reporter","node-reporter","sonarqube","sonarcloud","typescript"],"install":[{"cmd":"npm install node-reporter-sonarqube","lang":"bash","label":"npm"},{"cmd":"yarn add node-reporter-sonarqube","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-reporter-sonarqube","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import SonarQubeReporter from 'node-reporter-sonarqube';\nconst reporter = new SonarQubeReporter();","symbol":"Reporter instantiation (incorrect)","correct":"This package is not imported into JavaScript/TypeScript code. It is used exclusively via Node.js CLI arguments."},{"note":"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.","wrong":"import { createSonarQubeReporter } from 'node-reporter-sonarqube';","symbol":"Named import (incorrect)","correct":"Utilize `node --test --test-reporter=node-reporter-sonarqube` directly from your shell or npm script."},{"note":"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.","wrong":"const sonarqube = require('node-reporter-sonarqube');","symbol":"CommonJS require (incorrect)","correct":"Ensure `node-reporter-sonarqube` is installed as a `devDependency` and configured via `package.json` scripts or direct CLI calls."}],"quickstart":{"code":"npm install --save-dev node-reporter-sonarqube\n\n# Configure your package.json scripts for convenience\n# For example, in your package.json:\n// \"scripts\": {\n//   \"test:sonarqube\": \"node --test --test-reporter=node-reporter-sonarqube --test-reporter-destination=test-report.xml\"\n// }\n\n# Run your Node.js tests and generate the SonarQube report\nnode --test --test-reporter=spec --test-reporter-destination=stdout \\\n  --test-reporter=node-reporter-sonarqube --test-reporter-destination=test-report.xml\n\n# This will output standard test results to stdout and a SonarQube-compatible XML to test-report.xml\n# You would then typically upload test-report.xml during a SonarQube/SonarCloud scan.","lang":"bash","description":"Demonstrates installation and basic command-line usage to generate a SonarQube compatible test report using the Node.js Test Runner."},"warnings":[{"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`.","message":"When 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"In your SonarCloud GitHub Action or Sonar Scanner CLI, ensure `-Dsonar.testExecutionReportPaths=path/to/test-report.xml` is present and accurate.","message":"For 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`).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update to `node-reporter-sonarqube` v1.0.1 or later to ensure relative paths are correctly generated in the `test-report.xml`.","message":"Prior 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.","severity":"gotcha","affected_versions":"<1.0.1"}],"env_vars":null,"search_vec":"'1.0.3':75 'analysi':67 'argument':110 'built':42 'built-in':41 'cadenc':82 'code':65 'command':108 'command-lin':107 'compat':103 'consum':61 'current':71 'data':52 'depend':87 'design':19 'differenti':99 'direct':102 'enabl':26 'execut':134 'featur':96 'fix':91 'focus':80 'framework':127 'frequent':94 'generat':47 'generic':50 'integr':28,131 'issu':84 'javascript':117,136 'key':98 'line':109 'maintain':78 'make':111 'manag':88 'metric':69 'minor':90 'nativ':22,124 'new':95 'node':10,39,105,141 'node-report':140 'node-reporter-sonarqub':9 'node.js':5,23,125 'output':37 'packag':13 'platform':33 'primarili':83 'process':35 'project':77,120 'provid':14 'qualiti':66 'rather':92 'releas':81 'report':3,11,18,54,135,139,142 'requir':129 'runner':7,25,45 'seamless':27 'solut':115 'sonarcloud':32,144 'sonarqub':1,12,30,143 'sonarqube/sonarcloud':63,130 'special':16 'stabl':72 'standard':49 'straightforward':114 'test':2,6,17,24,44,51,106,126,133,138 'test-report':137 'test-report.xml':56 'track':70 'typescript':119,145 'typic':55 'updat':85 'util':122 'version':74 'xml':53","created_at":"2026-04-20T01:55:37.841127+00:00","updated_at":"2026-04-20T01:55:37.841127+00:00","problems":[{"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.","cause":"The package is not installed or Node.js cannot resolve its path.","error":"Error: Reporter 'node-reporter-sonarqube' not found"},{"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.","cause":"The SonarQube/SonarCloud scanner could not find the `test-report.xml` file at the specified path.","error":"Failed to read test execution report: file 'test-report.xml' not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/sjinks/node-reporter-sonarqube","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/node-reporter-sonarqube","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}