Sonar cloud scanner fail to capture the codecoverage for the nextjs react code

sonarcloud

(Niraj Cricket) #1

It always fails to capture any coverage, what could be the best possible inclusion or exclusion, i am running a scan on a GitHub repo via azure-devops pipelines using sonarcloud.


(Fabrice Bellingard) #2

Can you please give more context? It’s difficult to help with so little information. Like:

  • What type of project are you trying to analyze on Azure DevOps?
  • How do you trigger the analysis?
  • Does SonarCloud successfully import your JS source code? (i.e. do you see it in SonarCloud along with issues that were found)

(Niraj Cricket) #3
  1. it is a nextjs react based code
  2. via azuredevps pipeline using sonarcloud integration tool
  3. Yes, my codes are imported in sonarcloud, but cov is 0.0%
  4. it happens with all react/nextjs based code

(Fabrice Bellingard) #5

Great, thanks for the details, it’s much clearer to me now :slight_smile:

I guess that the following will help you:

  • You must make sure that the execution of your unit test produces an LCOV report file
  • You need to configure the “Prepare analysis” step with the following additional parameter: sonar.javascript.lcov.reportPaths
    • This is a comma-separated list of paths to LCOV coverage report files

And with this, you should get the coverage in SonarCloud.


(Niraj Cricket) #7

it works, when i pointed my lcov.info file