Code coverage not being displayed on SonarCloud even with all config set

Project info: Front End with JS/React
I have followed all the instructions to integrate sonarCloud scan with my front end project from this documentation
I followed everything through, the integration has been done successfully and I see sonarcloud being triggered on github actions.
However when I go to sonarCloud dashboard it is not being displayed.
I have an example of the projects we have on the screenshot: Project 1 displays the coverage, project 2 (the one I’ve been working on) does not display. And that’s what I’m trying to get:

  • I already double checked all the config added: I’ve added a file to the root that looks like this (update the info according to my organization):
sonar.sources= src
sonar.exclusions= src/components/atoms/HeadDocument/HeadDocument.js, src/components/atoms/NextScriptDocument/NextScriptDocument.js

I compared with what has been done to project 1, and what I did was exactly the same, but for project 2 doesn’t work.
I have added to .github/workflows/test.yml the additional sonarConfig:

name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@v1.6
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          args: >
            -Dsonar.pullrequest.key=${{ github.event.number }}
            -Dsonar.pullrequest.branch=${{ github.HEAD_REF }}
            -Dsonar.pullrequest.base=${{ github.BASE_REF }}
            -Dsonar.pullrequest.github.repository=${{ github.repository }}

Anyway, I don’t know what else to do.
So appreciate some help please :pray:

Hey there.

Even if 0.0% coverage was being reported, it should still show up on your dashboard.

So let’s assume for a moment that coverage is being imported correcty.

The only two ways to have null coverage reported would be

  • Zero Executable Lines (unlikely if your project has Javascript in it)
  • All files are being excluded from coverage.

Let’s consider the second for a moment. In your scanner logs you should have some logs like this, can you see if there are any files being marked as excluded sources for coverage?

INFO: Project configuration:
INFO:   Excluded sources: **/build-wrapper-dump.json, **/*.spec.ts
INFO:   Included tests: **/*.spec.ts
INFO:   Excluded sources for coverage: **/*
INFO: 1 file indexed

Hello Colin, thank you for your reply :slightly_smiling_face:
On my project we have configured that the coverage files to be excluded as the following (we use jest for it):

collectCoverageFrom: [

And this is how the file is file is currently:


sonar.sources= src/components
sonar.exclusions= src/components/atoms/HeadDocument/HeadDocument.js, 


So I don’t see why would that be the source of the coverage not being displayed :confused:

Hey there.

I appreciate the additional information, but I really suggest stepping back to the previous question about what you see in the scanner logs.

Sorry I misunderstood your question.
I took a screenshot of what I have in the logs regarding what you asked, here you go:

I also noticed in the logs the following:

Update: I merged this to our develop branch, once I did, the 0.0% appeared on sonar dashboard - At least some progress :sweat_smile:
But when I check the logs I still see the coverage pointing for jacoco. And I don’t get it why, since the path I passed is correct.

Hey there.

The JaCoco XML Report Importer will show up on every analysis despite what languages/analysis parameters are passed. But there should be a section specific to import of javascript LCOV reports.

INFO: Sensor JavaScript/TypeScript Coverage [javascript]
INFO: Analysing [/home/vsts/work/1/s/test-results/coverage/]
INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=48ms

Do you see something like this in your log files, and any associated warnings/errors?

This is the closest I could find to the example you just shared on line 85:

@Colin to test a theory here, I added to the yml file - run: ls (after the action- run: yarn test:coverage)
and pushed the changes. With that I noticed that the the folder coverage was not created in the step before, and that’s why it’s null.
Then I manually deleted the folder coverage and ran yarn test:coverage -u

This way the folder is generated but we know that this is not the way.

How to solve that? I still don’t know :sweat_smile:

Hey there.

It’s best if we stay focused on a single topic – let’s make sure that the Sensor JavaScript/TypeScript Coverage is running (that means that the scanner has identified a value is being passed to sonar.javascript.lcov.reportPaths) and then, once that’s taken care of, return to making sure the coverage report is generated in the right place (which is not much of a SonarCloud issue).

I’m a bit worried your file might be in a werid state, or that settings are being passed somewhere you aren’t aware of. For example, did you notice that here;

sonar.exclusions is tacked onto Excluded sources for coverage? That shouldn’t be happening.

Let me suggest this:

  • Please make sure that all values in your file are configured correctly, this means removing the spaces between <analysis paramter>= value and that each anlalysis parameter takes up one line (it looks like your second file for sonar.exclusions is on a new line)

This would look something like:



  • Under project level Administration > Background Tasks, open up the SonarScanner context of an analysis that should have coverage reported and paste it here.

@Colin I update my file as you suggested. Making sure there are no spaces. Now it looks like this (I adjusted the sonar.sources only for src)


sonar.exclusions=src/components/atoms/HeadDocument/HeadDocument.js, src/components/atoms/NextScriptDocument/NextScriptDocument.js


And here’s the screenshot as requested from Administration > Background Tasks:

Thanks again for your help so far :blush:

@alineborak You’ll need to actually open up the Scanner Context (as pointed to by an arrow in the screenshot) and paste it here.

SonarCloud plugins:
  - IaC Code Quality and Security (iac)
  - PL/SQL Code Quality and Security (plsql)
  - Scala Code Quality and Security (sonarscala)
  - C# Code Quality and Security (csharp)
  - Vulnerability Analysis (security)
  - Java Code Quality and Security (java)
  - HTML Code Quality and Security (web)
  - Flex Code Quality and Security (flex)
  - XML Code Quality and Security (xml)
  - VB.NET Code Quality and Security (vbnet)
  - Swift Code Quality and Security (swift)
  - CFamily Code Quality and Security (cpp)
  - Python Code Quality and Security (python)
  - Go Code Quality and Security (go)
  - JaCoCo (jacoco)
  - Kotlin Code Quality and Security (kotlin)
  - Mercurial 1.1.2 (scmmercurial)
  - T-SQL Code Quality and Security (tsql)
  - Apex Code Quality and Security (sonarapex)
  - JavaScript/TypeScript Code Quality and Security (javascript)
  - Ruby Code Quality and Security (ruby)
  - Vulnerability Rules for C# (securitycsharpfrontend)
  - Vulnerability Rules for Java (securityjavafrontend)
  - License for SonarLint (license)
  - Vulnerability Rules for JS (securityjsfrontend)
  - COBOL Code Quality (cobol)
  - Vulnerability Rules for Python (securitypythonfrontend)
  - PHP Code Quality and Security (php)
  - ABAP Code Quality and Security (abap)
  - Configuration detection fot Code Quality and Security (config)
  - Vulnerability Rules for PHP (securityphpfrontend)
Global server settings:
  - email.fromName=SonarCloud
  - email.prefix=[SonarCloud]
  - node_10_end_of_support_date=1620604800000
  - node_10_grace_period_termination_date=1621814400000
  - sonar.auth.bitbucket.enabled=true
  - sonar.core.serverBaseURL=
  - sonar.core.startTime=2021-12-15T11:20:40+0100
  - sonar.dbcleaner.weeksBeforeDeletingAllSnapshots=260
  - sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByMonth=4
  - sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek=1
  - sonar.lf.enableGravatar=true
  - sonar.lf.logoWidthPx=105
  - sonar.organizations.anyoneCanCreate=true
  - sonar.organizations.createPersonalOrg=true
  - sonar.plsql.file.suffixes=sql,tab,pkb
  - sonar.tsql.file.suffixes=.tsql
Project server settings:
  - sonar.autoscan.enabled=false
  - sonar.coverage.exclusions="src/components/atoms/HeadDocument/HeadDocument.js, src/components/atoms/NextScriptDocument/NextScriptDocument.js",sonar.exclusions
  - sonar.javascript.lcov.reportPaths=src/coverage/
  - sonar.scm.disabled=true
  - sonar.typescript.tsconfigPath=src/tsconfig.json
Project scanner properties:
  - sonar.exclusions=src/components/atoms/HeadDocument/HeadDocument.js, src/components/atoms/NextScriptDocument/NextScriptDocument.js
  - sonar.javascript.lcov.reportPaths=coverage/
  - sonar.organization=abc
  - sonar.projectBaseDir=/github/workspace
  - sonar.projectKey=Company_project_react
  - sonar.pullrequest.base=
  - sonar.pullrequest.branch=
  - sonar.pullrequest.github.repository=Company_project_react
  - sonar.pullrequest.key=
  - sonar.scanner.appVersion=
  - sonar.scm.provider=git
  - sonar.sourceEncoding=UTF-8
  - sonar.sources=src/components
  - sonar.typescript.tsconfigPath=src/tsconfig.json

Update: This problem has not been solved yet, so if anyone from SonarCloud community can help, that would be really appreciated :innocent: