Right tool for creating jest test results to be sent to SonarQube

Hi Sonar Community,

We are working on reference implementations including unit testing javascript/typescript source code with jest framework in a CI/CD pipeline, and currently we are trying to figure out the best practises how to integrate and pass the test reports created by jest to SonarQube.

A post in this community and documentation about analysis parameters refer to jest-sonar-reporter to create the reports in a proper format to be sent to SonarQube. This tool in question is an archived project in GitHub though it still looks to have a high number of weekly downloads in npmjs.com. We’ve found that there’s also jest-sonar available via npm which seems to be an active project for the same purpose of creating test result reports.

We’d like to hear community’s opinion on what tool to pick for the purpose. Is the jest-sonar-reporter still a valid choice or should we pick a tool that is actively maintained?

1 Like

Hello Mikko,

Thank you for your message, and welcome to SonarSource community!

As it is described in SonarQube documentation about importing coverage data, the JavaScript/TypeScript analyser supports LCOV-based test coverage reports. You can import such reports in SonarQube through the scanner with the sonar.javascript.lcov.reportPaths property. Your CI/CD pipeline would then essentially need to run the unit tests, generate the test coverage report, and tell the scanner where to find it.

Hope this helps,