angularjestjssonarqubets-jest

sonaqube jest coverage cannot resolve file paths


I have an Angular project using Jest 29.5 for unit test coverage. I am getting the following error

"Could not resolve 199 file paths in [workspace/source/Content/angular-project/coverage/lcov.info]

First unresolved path: Content/angular-project/src/app/app.component.html

My jest.config.ts file has the following coverageReporters:

coverageReporters: ['html', ["lcovonly", {"projectRoot": "../../"}], 'text-summary'],

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.


Solution

  • It turns out we have 2 sonar projects connected to the same repo. I don't know why, but the second one is reporting coverage fine, so this appears to be an issue with sonar configuration on one of the projects and not an issue with jest configuration.