Sonar | Unit Test Missing | NPM Project

Context: Unit Test not appearing in Sonar Dashboard
SonarQube: 7.4
Sonar Scanner: sonar-scanner-4.5.0.2216
Project: NPM (Node Javascript platform)

I tried to tweak around passing parameters but Unit Tests not appearing in the Sonar dashboard

Sonar Scanner Command:
$> /opt/tools/sonar-scanner-4.5.0.2216-macosx/bin/sonar-scanner -Dsonar.host.url=http://sonar.localhost.com -Dsonar.sourceEncoding=UTF-8 -Dsonar.qualityGate=API -Dsonar.projectKey=project-1 -Dsonar.projectName=project-1 -Dsonar.projectBaseDir=. -Dsonar.sources=src -Dsonar.tests=config/jest/unit -Dsonar.javascript.lcov.reportPaths=dashboard/unit-testing/lcov.info

After successful execution of the above command, it generates below files

ll dashboard/unit-testing

ll dashboard/unit-testing/lcov-report

At Sonar dashboard:

My Unit Test getting missed in Sonar dashboard Coverage - It would be helpful if you share any pointers.
Appreciate your response.

Hi,

First, there are several elements in your analysis command that are unnecessary:

-Dsonar.qualityGate=API - you can’t set Quality Gate from the command line, so this doesn’t do anything
-Dsonar.projectKey=project-1 -Dsonar.projectName=project-1 - project name will default to project key if you don’t supply a value. Since you’re using the same string for both you could omit sonar.projectName and save yourself a few keystrokes, altho it doesn’t hurt anything to supply it explicitly
-Dsonar.projectBaseDir=. - . is the default value. No need to make it explicit.

To be clear, SonarQube analysis isn’t going to generate any of those files. When properly configured, it may read them, though.

The project homepage screenshot you’ve provided makes it look like there haven’t been any code changes in the… last 24 minutes. Did you actually make code changes and re-analyze?

 
Ann