Code Coverage Percentage for Angular project

Hi everybody, I can not see code coverage percentage for my project (Climb.web project it’s an angular project) in sonarCloud , I did some things like install “sonar-scanner”: “^3.1.0” and added on my package.json file, install “tslint-sonarts”: “^1.9.0” and added in the same file too, I created the “” file in the root path of my project with the follow configuration:

but finally I can not see code coverage on my project, if you can give me some help I appreciate that

I dont know if I have to configurate something in my Karma.conf.js or in other file, I don’t know if the “”" file configuration is right (for example I login sonarcloud with my github credentials, so is it those credentials that I should use in that “” file? ).

so I appreciate any help or session

Hi @boterito3, welcome to the SonarSource Community!

Have a look here, I have an example project created for this purpose. You’ll see the key is to exclude the test files from being considered as source, then making sure they are included as tests.

1 Like

Hi Jeff , thank you so much for response my question, your project help me to configure my karma.conf.js file and I can create in my local enviroment a Code Coverage Report as you can see in this Image:

but I don know how to send that report to sonacloud yet, how to call sonnar scanner from CLI to send that report, I have a build in Azure for my project and that build is telling me that can not found any coverage file to be uploaded, so I think that coverage report is not be generating by any reason.

in your project I checked the file and there I see you run the test and after that you
call sonar scanner:
sonar-scanner$SQ_URL -Dsonar.login=$SQ_TOKEN
I put my URL and my token but CLI not recognized the command.

if you can help me with any tip to do that, thank you

Hi @boterito3,

In my example repo, the file src/karma.conf.js includes configuration to generate the coverage report using the karma-coverage-istanbul-reporter plugin.

How you send the report to SonarCloud is shown in the file in the property sonar.javascript.lcov.reportPaths which is set to the output from the coverage report generated by karma.