0% coverage reported in Sonar UI on some files that do have test coverage

I don’t have any transformations happening during the build process that would cause this, but I searched for related errors in this forum and found someone else who had the same problem as me. It seems that my problem is that in my monorepo (which I didn’t realize would be relevant, which is why I didn’t include it in my initial post) I have files at the same relative path in 2 different folders and am generating the coverage in each of those folders independently. Every one of the lines about processing the LCOV report where “line doesn’t belong to file” are about files in folderA which have a matching route in folderB. I run my tests in each folder and then sonar scan with all of the files in place where they were originally generated. folderB/coverage/lcov.info includes SF paths that are relative to folderB, but there are files at the same relative path in folderA, so I’m assuming that the sonar scan doesn’t consider the context/location of the coverage file that it is analyzing.

I have now solved this issue by setting my --cwd option for my test command (using nyc) to the root of the monorepo, so that the lcov files include more context in the source file paths (folderA/app.ts and folderB/app.ts rather than just app.ts). I am still confused on why this happened also for file paths that only exist in one module, but the issue is resolved now, so the answer isn’t all that important at this point.

Thanks so much for commenting and leading me to find the information that I needed!

1 Like