When I change my coverageReporters projectRoot to the absolute path, the lcov.info file changes the file paths to be relative, so they do not match the relative path in the projectRoot provided. With both relative and absolute paths I am receiving this error. I have seen other responses suggesting sed cli to update the files, however my work does not allow this cli to be downloaded. How can I ensure sonarqube is able to resolve the paths?
As you’ve probably seen in your research, this is caused by the paths in the coverage report not matching the paths analysis sees.
I’m no Jest expert, so I can only ask: would executing Jest from a different directory (presumably the same directory that analysis is kicked off from) get you a report with matching paths?
Thanks for the response.I was able to resolve this error however, and now I no longer get the error “cannot resolve file paths”, by removing “src” from moduleDirectories. However, Sonar is still not reporting coverage. Now I am getting the following:
Info: NO LCOV files were found using **coverage/lcov.info. Info: Analyzing [workspace/source/Content/angular-project/coverage/lcov.info] ... Info: 0/0 source files have been analyzed
I was previously using Karma and it was reporting fine with the same coverage path and executing from the same directory as Jest is currently configured from. Sonarqube read the lcov.info file from the same coverage directory without issue, so I can only assume since the only change was with Jest, it is an issue with the Jest configuration, however I was not sure if there is a sonarqube configuration that needed to be changed to work with Jest. I had to switch from Karma due to incompatibilities with other parts of the repo after I fixed some vulnerabilities. Currently Jest is the only other option my company supports for Angular, however my DevOps team has also not been able to help yet on why coverage is not reporting.
The Plot Thickens! While looking for the reports, I found a second Sonar project connected to the same repo, and it turns out it is reporting coverage fine. For some reason we have 2 Sonar projects set up, and one shows the coverage, while the one linked on our Bitbucket repo shows no coverage. It looks like we’ll just need to remove the incorrectly built second project and all will be good.