Angular projects Unit test cases

Hi Team,

In the organization I work for, we are using Jasmine and Karma for writing the unit test cases for Angular projects. For those projects the unit test cases are not shown in the sonarcloud, where as the coverage for those projects is shown.
Is there any way we can get the unit test cases metric in sonarcloud.
Any help is appreciated.

Thanks,

Hi,

Yep, there is a way:) You should rely on generic code coverage https://sonarcloud.io/documentation/analysis/generic-test/
Property is sonar.testExecutionReportPaths. See this project https://github.com/tobiashofmann/karma-sonarqube-generic-reporter for convertion (note it’s a community project, not maintained by SonarSource)

Hi Elena,

Appreciate your reply.
My concern here is in respect to the missing unit test cases number for Angular projects which are not visible on sonarcloud unlike the regular dot net projects. please find the below screenshot for the same.
1st image is the dotnet projects report and the bottom image is the angular projects report.
image

Is there any way that we can see the unit test metrcis on sonarcloud UI for angular projects also.
For dot net projects we are using VSTest Assemblies task. And for Angular projects we are obtaining the report from Karma.

Our Organziation Setup:
Azure DevOps with SonarCloud.

Any help is appreciated!

Did you provide sonar.testExecutionReportPaths property for second project?
What is in the logs?

You should follow such scheme:

  1. generate Karma report
  2. convert this report to generic format
  3. set path to this converted report as the value for sonar.testExecutionReportPaths property
  4. run analysis

Hi SonarCloud Team,
We are not getting code coverage for any of the Angular projects in SonarCloud through Azure Devops.
Has anything change?
Earlier we were getting it but from a month we tried multiple ways but not getting any coverage for Angular projects.

Any help or suggestions please!!

Thank you.

Hi Sonar Team,
Any update on my last query please?

Thnak you!