Jest lcov file mismatch with sonarqube coverage

We have a problem with mismatch between what jest coverage returns in the file with what sonar scanner identifies. From the log it seems like sonar converts vue files to javascript code, although our vue files are in typescript and they have different lines.

The analysis runs in a pipeline in gitlab. And we use the docker image sonarsource/sonar-scanner-cli:4.8.

Sonar config:

sonar.exclusions= **/__mocks__/**/*,**/*.spec.ts
# Language

Attached the log and the lcov file.
job.txt (471.0 KB) (110.4 KB)

Please help.

Hey there.

From the logs it just looks like lines that don’t exist are being referenced in the report. What makes you believe the files are being convereted to Javascript code?

Hi Colin. Thanks for the answer. I’m assuming that from lines like these in the log: 12:50:33.669 DEBUG: 'src/components/address-input.vue' indexed with language 'js'.

But I’ve been trying a few things and it might be because we have a custom vue transformer to deindent our pug template, because of an indentation error with the jest engine (an older version that we cannot update at the moment). So I’m looking into how to add a custom transformer for vue for sonar if it exists.

Thanks. At the end of the day, the indexing is a rather internal detail I don’t think is important here.

I think it might be useful for you to just cat one of the files mentioned in the logs in your build pipeline (before/after the SonarQube analysis) and see if it matches the number of lines you expect.

Ok. Thanks. Will try that.