2

Sonarqube is currently reporting the percent coverage of the project, but not the number of unit tests. I am using jest-sonar-reporter, so a test-report.xml file is being generated after tests run. Looking that the Sonarqube log, it says test execution data is imported for 0 files.

INFO: Parsing /builds/REPONAME/coverage/test-report.xml
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 153 unknown files, including:
*file names*

The file paths in my test-report.xml file are:

<file path="/builds/REPONAME/src/accounts/.../utils.test.ts">
<file path="/builds/REPONAME/src/shared/.../utils.test.js">
etc.

package.json file:

  "devDependencies": {
    ...
    "jest-sonar-reporter": "2.0.0",
    ...
  },
  "jestSonar": {
    "reportPath": "coverage",
    "reportFile": "test-report.xml",
    "indent": 4
  },

sonar-project.properties file:

sonar.projectName=REPONAME
sonar.projectVersion=3.46.1
sonar.language=js
sonar.sources=src
sonar.tests=src
sonar.exclusions=node_modules/**,tests/**,.idea/**,.storybook/**,stories/**
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.test.inclusions=**/*.test.*
sonar.coverage.exclusions=node_modules/**,test/**,src/**/*.test.js,src/**/*.test.jsx,server/**/*.test.js,*.config.js,.idea/**,.storybook/**,stories/**,**/__snapshots__/**/*
sonar.eslint.reportPaths=eslint.json
sonar.testExecutionReportPaths=coverage/test-report.xml
Lindsey
  • 61
  • 1
  • 7
  • Can you provide more information such as is this a single application project, a monorepo, etc. Why I ask this is because the plugin has issues finding the generated files when not using proper paths in the generated .xml files. I deleted my answer - it should have been a comment. – CasualBot Mar 01 '22 at 17:15

0 Answers0