SonarCloud Analysis for JavaScript application

Hi,

I am trying to publish code coverage results for our Vue JS application in Azure DevOps. I am having trouble generating LCOV report file as suggested in the sonar documentation.

could anyone suggest me, how to integrate code coverage from Azure pipeline to sonar and get code coverage results?

Can you please describe how you’ve configured your Azure Pipeline? You need to make sure that you run at least a task which will execute the tests with code coverage. And configure the “Prepare SonarCloud Analysis” task to specify the sonar.javascript.lcov.reportPaths property to point to the LCOV file(s).

1 Like

I have configured “PrepareSonarCloud Analysis” with additional parameters as
sonar.sources=src
sonar.sourceEncoding=UTF-8
sonar.tests=tests/unit
sonar.javascript.lcov.reportPaths=tests/lcov.info
sonar.javascript.coveragePlugin=cobertura
sonar.javascript.junit.reportPath=test/junit.xml
sonar.javascript.jslint.reportPath=**/*.eslintrc.js
sonar.language=js
sonar.issuesReport.html.enable=true
sonar.issuesReport.console.enable=true

I have a quick question again do we need to generate LCOV files or it generates by itself from that property because I have created an empty file manually in my “Repo” and gave that path as mentioned above. For unit test I tried with “VStest” task and “publish code coverage task with Cobertura” in my Azure pipeline. I have even tried with “Yarn test” to run my unit test but it did not support.

Are there any changes needed to be done in my code or package.json file? @Fabrice_Bellingard

Thanks!

1 Like

Yes, you need to configure your pipeline so that it generates the LCOV files, which will then be used by the “Run Analysis” task. Only you know how to do that, this is out of our scope.
And once you’ve figured out how to generate the LCOV file, then you need to use only the sonar.javascript.lcov.reportPaths property, not all the other ones that you tried.

Thank You @Fabrice_Bellingard