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

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.

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)
  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

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.

it works, when i pointed my file