Coverage issues for Typescript (LCOV Could not resolve file paths)

Hey in one of our Projects we have encountered a strange issue. The project is in Typescript and during the introduction of branch support and PR decoration we found out, that currently, we have no code coverage. We have Typescript as the project language and up until a few weeks ago code coverage was working properly.
Versions:
- SonarQube 7.4.0.18908
- Scanner 3.2.0.1227-linux
- SonarTS 1.8 (build 3332)

We did not do any updates to the above mentioned plugins and altough I can see there is a newer version of SonarQube as well as SonarTS available this seems odd to me.

The issue is that all files that need to be resolved for the coverage (with LCOV) to work, cannot be resolved. I have gone ahead and resolved one of the filepaths manually and now that file has code coverage. The error message is:

WARN: Could not resolve xx file paths in [coverage/lcov.info], first unresolved path:

With xx beeing the number of files we want code coverage for.

Are there any recommended steps to solve this issue?

Hi,

When resolving a path from a coverage report, it should be either absolute or relative to project directory. Otherwise corresponding file is not found. What is it in your coverage report? what’s wrong with your paths?

Hey Elena,
thanks for the quick reply.

The contents of the lcov.info file are:
/file_name.ts
Coverage-data
/file_name1.ts
Coverage-data

followed by the analysis data. The data seems to be correct, because when I change this to the real path:
~/Projects/project_name/src/path_to_file/file_name.ts
It is working.

So I don’t know if this is actually related to sonar or is a bug with LCOV or yarn coverage.

Indeed, this path starts from slash, thus it will be considered absolute by Sonarqube while it’s not. Check if you changed something in the way you generate this report.

Was a bug with typescript, fixed it using this. Thanks for the help.

@Lena. Please help with this issue.

Hello Team, I am seeing same issue for my typescript project. I did see data on lcov.info after the scan. Due to this LCOV path resolve issues, sonar dashboard is not having coverage report (always shows ‘0’). Please do the needful.

My settings are
sonar-scanner
-Dsonar.projectKey=email-process-api
-Dsonar.host.url=http://XXX.XX.XXX.44:9000
-Dsonar.login=XXXX085905cde1d81bbXXXXXXXX
-Dsonar.test.inclusions=[’.spec.ts’,’.test.ts’,’//*.spec.ts’,’//.test.ts’,'test/**/.ts’]
-Dsonar.sources=.
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.exclusions=[’.js’,’**/.spec.ts’,’.spec.ts’,’**/.test.ts’,’*.test.ts’]

any updates on this issue?