Coverage reports not accurate Vue 3 + Typescript

Hello,

We currently work on a project used Vue 3 + typescript and reports coverage seems to be not accurate.

With the same lcov.info provided, we have differences between local and ci environments.

In vue 3 components single file with typescript support, import statements are not covered in sonarcloud while it is not the case in local environment.

Sonar Scanner : v4.7.0.2747 (sonarqube-scanner npm package)
CI : Github actions
Langage : Vite + Vue 3 + Typescript
Unit / Acceptance tests : Jest 26.6.3, vue-jest 5.0.0-alpha.10
Component tests : Cypress 10.3.0, nyc 15.1.0

Have you already encountered this issue ? Have you got a solution to fix this issue?

Thanks in advance,

Regards,

Hey there.

When you speak about your local environment – what are you referring to? A SonarQube instance? Another visualization of your coverage data?

Hello,

Thank you for your response.

We use nyc to instrument code coverage and run our components tests with cypress, it generates lcov.info and reporter html.
We use jest to instrument code and run our acceptance tests, it generates lcov.info and reporter html too.

We both use the same tools in ci and local environement.

Import statements are correctly covered in local when I directly open the html report.
So I tried to use genhtml (a ubuntu package) to reverse lcov.info and generate html report because I think there is an issue with lcov.info provided to sonar ; Imports statements are still covered with this operation.

When we provide lcov.info which be generated in ci environement.

Here you are my sonar-project.properties :

sonar.projectKey=*********
sonar.sources=src
sonar.host.url=https://sonarcloud.io
sonar.organization=*******
sonar.typescript.lcov.reportPaths=reports/coverage/**/lcov.info

Import statements are not covered whereas any statements which use these import are covered.

Hello,

To complete my previous response, we don’t use a sonarqube instance to generate reports in local.
Any suggestions to give me in order to fix this issue ? We can’t put in place an accurate test strategy with this issue.

Any help is appreciated.

Hello cordier,

Would you have a code snippet or project template to share so we could reproduce your issue and investigate it?
Imports that are exclusively used for typing are not highlighted in Sonarqube, but they might not be in the coverage HTML either. Could that be the case in your issue?

Best,
Ilia

Hello,

Can you contact me, so we can discuss how to share our code?

Regards,

Hello cordier,

Could you paste here a piece of the file that contains the incomplete coverage?

Best,
Ilia

Hello Ilia,

I can’t provide a piece of the file because it’s corporate code.

I would like to investigate and share code with you in private.

Is it possible ?

Regards,

Julien