dazlious
dazlious

Reputation: 556

SonarQube and Karma code coverage - unresolved file paths

I searched a lot for this specific error, but I had no chance in finding a suitable answer.

I have SonarQube 5.4 and using newest Karma-version.

Following error occurs when running sonar-runner:

INFO: Analysing /Users/foo/repository/BarJS/test/reports/coverage/lcov.info
INFO: Could not resolve 6 file paths in lcov.info, first unresolved path: /Users/foo/repository/BarJS/test/spec/Classname.test.js

While foo is my username and BarJS is the name of the project.

Other people getting those errors having mispelled or case-specific or relative paths. I checked half a dozen times. My paths are correct.

I have absolute paths in my Karma lcov.info-file. All camelcase letters are equal to their path in Finder.

Content of Karmas lcov.info

SF:/Users/foo/repository/BarJS/test/spec/Classname.test.js

Anybody out there having same issue? It is really annoying

Upvotes: 3

Views: 5336

Answers (2)

lakshman
lakshman

Reputation: 2741

I also had the same issue. Sonar scanner log shows first unresolved path: ./app/modules/abc.js as the error. The reason for my issue was, my sonar-project.properties file was in a parent directory rather than app folder. I could be able to solve the issue by changing the directory paths in lcov.info file to relative paths from the directory which is sonar-project.properties resides.

ex: sonar-project.properties file was in a folder called WebContent. lcov.info file shows SF:./app/modules/abc.js as file path. After changing this to SF:./WebContent/app/modules/abc.js, test result published to sonar without any issue.

Upvotes: 2

dazlious
dazlious

Reputation: 556

In my case, the solution was to add

sonar.tests=test/spec 

to my sonar.properties. Now it is working like a charm

@ElenaVilchik: many thx for your direction, helped a lot

Upvotes: 2

Related Questions