- Unit Tests but 93% Coverage on 100 lines - Javascript LCOV working but not JUnit

  • Which versions are you using
    • SonarQube™ 8.9.3
    • Scanner 5.2.0
    • JavaScript/TypeScript Code Quality and Security (javascript)
    • SonarTS (typescript)
    • XML Code Quality and Security (xml)
    • Much more but not relevant I think :slight_smile:
  • What are you trying to achieve
    I get everything in SonarQube except the Unit Tests
  • What have you tried so far to achieve this
    I read many topics here and tried many different settings - see below

I set up my Angular project as easy as possible.
Then I added SonarQube as described here: JavaScript/TypeScript/CSS | SonarQube Docs
and Test Coverage & Execution | SonarQube Docs

The Jest configuration is simple, too.

  reporters: ['default', ['jest-junit', { outputFile: './coverage/junit.xml' }]],
  coverageReporters: ['lcov'],

Then I add all reports as properties.


And in SonarQube then I can see mostly everything - except the Unit Tests.

  • Bugs
  • Vulnerabilities
  • Security Hotspots
  • Debt’s
  • Code Smells
  • Coverage (93%, Coverage on 100 Lines to cover) - Unit Tests
  • 0% Duplications on 260 Lines
  • In Issues tab the ESLINT tagged issues are shown

When I try out this things nothing changes.


And with that configuration:


I’m getting:

ERROR: Error during parsing of the generic coverage report '/coverage/junit.xml'. Look at SonarQube documentation to know the expected XML format.
ERROR: Caused by: Unknown XML node, expected "coverage" but got "testsuites" at line 2

The junit.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="2" failures="0" errors="0" time="0.943">
  <testsuite name="..." errors="0" failures="0" skipped="0" timestamp="2022-02-05T13:33:33" time="0.252" tests="2">
    <testcase classname="..." name="..." time="0.059">
    <testcase classname="..." name="..." time="0.009">

And a last try before I post this…


But flex, python and php are skipped because there is no related file in current project. :unamused:

Any ideas? Thanks in Advance!


Property sonar.junit.reportPaths you are using is for Java and Kotlin. For JS/TS please check this doc Test Coverage & Execution | SonarQube Docs (Javascript and Typescript under Test execution analysis parameters). There you will find how to generate generic report, that’s how you provide tests info for JS/TS