Test execution data ignored

OS: windows 10
SonarQube: v10.3

SonarScanner: v5.0.1

Jest: v29

casualbot/jest-sonar-reporter : 2.2.5

Sonar deployed from zip

I’d like to see the number of executed tests.

Jest config

"jest":{
    "coverageDirectory": "coverage",
    "coverageReporters": [
      "lcov"
    ],
    "reporters": [
      "default",
      "@casualbot/jest-sonar-reporter"
    ]
  },
  "@casualbot/jest-sonar-reporter": {
    "uniqueOutputName": "false",
    "usePathForSuiteName": "true",
    "relativePaths": "true",
    "outputdirectory": "coverage"
  }

test-c.zip (260.6 KB)

coverage/
src/
    sourse/sum.ts
    test/sum.test.ts

18:17:08.478 INFO: Sensor Generic Test Executions Report
18:17:08.479 INFO: Parsing C:\GitHub\test-sonar\coverage\jest-sonar.xml
18:17:08.504 INFO: Imported test execution data for 0 files
18:17:08.505 INFO: Test execution data ignored for 1 unknown files, including:
sum.test.ts
18:17:08.506 INFO: Sensor Generic Test Executions Report (done) | time=27ms

fulllog.txt (58.9 KB)

sonar-scanner^
 -X^
 -D"sonar.projectBaseDir=src"^
 -D"sonar.projectKey=test-c"^
 -D"sonar.sources=sources"^
 -D"sonar.test=test"^
 -D"sonar.test.inclusions=test/*.test.ts"^
 -D"sonar.host.url=http://localhost:9000"^
 -D"sonar.token=sqp_49ae8893eb3e2b7ccb928ae7a3d198888afb028d"^
 -D"sonar.typescript.lcov.reportPaths=coverage/lcov.info"^
 -D"sonar.testExecutionReportPaths=coverage/jest-sonar.xml"^

report what i’ve tried

<testExecutions version="1">
 <file path="src\test\sum.test.ts">
  <testCase name="sum module adds 1 + 2 to equal 3" duration="3"/>
 </file>
</testExecutions>
<testExecutions version="1">
 <file path="test\sum.test.ts">
  <testCase name="sum module adds 1 + 2 to equal 3" duration="3"/>
 </file>
</testExecutions>
<testExecutions version="1">
 <file path="sum.test.ts">
  <testCase name="sum module adds 1 + 2 to equal 3" duration="3"/>
 </file>
</testExecutions>

What have tried

  1. Configured sonar and jest
  2. execute the sonar scanner with proper configuration
  3. Investigate already opened topics
  4. investigate GitHub Issues

Hi,

Welcome to the community!

The default suspect here is always paths that don’t match up between what’s in the report and what analysis sees.

It seems that your tests are, very sensibly, in a test directory. So right off the bat, that’s a path mismatch: sum.test.ts vs test/sum.test.ts. I see that you’ve tried different variations on the path, and the log you’ve excerpted is likely from the 3rd iteration.

So that brings me to the next thing. I believe your test files aren’t being identified as tests. The parameter name is sonar.tests, with an ‘s’ at the end. Can you change that, go back to paths-from-project-root in your test execution report, and try again?

 
Ann