Coverage is shown as 0.0 % even i ran npm test

Must-share information (formatted with Markdown):

  • 8.6
  • what are you trying to achieve: npm test – --coverage
  • what have you tried so far to achieve this: not able to get coverage %age in sonarqube server

Please help

Hi Mahender, welcome to the SonarSource Community!

After running your npm test command, it will be necessary to tell SonarQube about your test coverage by supplying the coverage report generated by npm to the sonar-scanner. Since you’re using npm, you’re probably analyzing JavaScript, and thus it will need to be an LCOV format report as per our docs that you must pass via the parameter sonar.javascript.lcov.reportPaths.

Thank you for your reply, Iam passing sonar-scanner -Dsonar.javascript.lcov.reportPaths=coverage/lcov-report/src/index.html

but still its not reflecting in sonar server, but i have a java project also i am able to get codecovereage there
only javascript is not able to get the reports

Please help

Hi Mahender,

In order to troubleshoot further, we’d need to see a copy of your analysis logs with debug-level logging enabled. In order to generate this, please invoke the sonar-scanner again with the -X parameter and redirect the output to a file, then zip it and attach to your response on this thread.

can you please tell me option to generate logs for sonar-scanner , iam getting error if i give below

[Container] 2020/12/29 06:10:30 Running command sonar-scanner -Dsonar.host.url=$SONAR_HOST -Dsonar.login=$SONAR_LOGIN -Xlogs.txt
976 [06:10:30] Starting analysis…
977 [06:10:30] Getting info from “package.json” file
978 [06:10:30] Checking if executable exists: /root/.sonar/native-sonar-scanner/sonar-scanner-4.5.0.2216-linux/bin/sonar-scanner
979 [06:10:30] Could not find executable in “/root/.sonar/native-sonar-scanner”.
980 [06:10:30] Proceed with download of the platform binaries for SonarScanner…
981 [06:10:30] Creating /root/.sonar/native-sonar-scanner
982 [06:10:30] Downloading from https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.5.0.2216-linux.zip
983 [06:10:30] (executable will be saved in cache folder: /root/.sonar/native-sonar-scanner)
984
985 ERROR: Unrecognized option: -Xlogs.txt