SonarQube code coverage stays at 0 with NodeJS project

Hi, i’m using Sonarqube 8.9 on a server at my university (provided by my institute) with sonar-scanner 4.6.0 on a Linux machine.
I’m building a NodeJS app using React and the Jest testing suit, and I’m trying to scan my code with sonar-scanner.
While the scan is successfull and the unit tests are recognized, the code coverage stays at 0, no matter what I try.
Here’s my sonar-scanner configuration:


The console.log created by sonar-scanner doesn’t appear to show any relevant errors, aside from this one:

INFO: Analysing [/[hidden_abspath]/ProgettoSWE/twitter-client/coverage/]
WARN: Could not resolve 1 file paths in [/[hidden_abspath]/ProgettoSWE/twitter-client/coverage/]
WARN: First unresolved path: src/Components/Loading.js (Run in DEBUG mode to get full list of unresolved paths)

which I don’t believe is what is causing the coverage to be 0.
Also, both the and the sonar-report.xml are not empty and contain some kind of information.

Any suggestions on what could be causing this? Thanks in advance.


Welcome to the community!

In looking at this, the thing I notice is the difference between


What I’m wondering is about the path from analysis root. Are you firing analysis off from /[hidden_abspath]/ProgettoSWE/twitter-client/?

Secondarily, I notice these analysis parameters, which I don’t believe are doing anything but muddying the waters:


Additionally, I would recommend dropping the exclusion setting until you get coverage working. Then you can add it back in:


Can you try those changes and post your full analysis log if you still don’t get what you expect?


thanks for your quick and detailed answer Ann. I’ve dropped the settings as you suggested, and now the file looks something like this:


I’ve kept the sonar.test.exclusion field, otherwise the scanner would return an indexing error for file overlapping.

I’m firing off the scanner in the current directory of the project (that is [hidden_abspath]/ProgettoSWE/twitter-client/). With that I mean I’m launching the command sonar-scanner in that directory.

In spite of this, though, the coverage still remains 0.

Here’s the full log as you’ve requested:

INFO: Scanner configuration file: /opt/sonar-scanner/conf/
INFO: Project root configuration file: /home/[hidden _abspath]/ProgettoSWE/twitter-client/
INFO: SonarScanner
INFO: Java 11.0.13 Oracle Corporation (64-bit)
INFO: Linux 5.11.4-1-rt11-MANJARO amd64
INFO: User cache: /home/agala/.sonar/cache
INFO: Scanner configuration file: /opt/sonar-scanner/conf/
INFO: Project root configuration file: /home/hidden _abspath/ProgettoSWE/twitter-client/
INFO: Analyzing on SonarQube server 8.9.0
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Load global settings
INFO: Load global settings (done) | time=321ms
INFO: Server id: 303924D4-AXnwGXk11Na4xCE_Oabm
INFO: User cache: /home/agala/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=105ms
INFO: Load/download plugins (done) | time=225ms
INFO: Process project properties
INFO: Process project properties (done) | time=24ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=2ms
INFO: Project key: team11-twitter-client
INFO: Base dir: /home/[hidden _abspath]/ProgettoSWE/twitter-client
INFO: Working dir: /home[hidden _abspath]/ProgettoSWE/twitter-client/.scannerwork
INFO: Load project settings for component key: 'team11-twitter-client'
INFO: Load project settings for component key: 'team11-twitter-client' (done) | time=58ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=109ms
INFO: Load active rules
INFO: Load active rules (done) | time=1753ms
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: **/__tests__/**
INFO:   Included tests: **/__tests__/**
INFO: Load project repositories
INFO: Load project repositories (done) | time=53ms
INFO: 60 files indexed
INFO: 5 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for css: Sonar way
INFO: Quality profile for js: Sonar way
INFO: ------------- Run sensors on module team11-twitter-client
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=62ms
INFO: Sensor CSS Metrics [cssfamily]
INFO: Sensor CSS Metrics [cssfamily] (done) | time=109ms
INFO: Sensor CSS Rules [cssfamily]
INFO: 1 source file to be analyzed
INFO: 1/1 source file has been analyzed
INFO: Sensor CSS Rules [cssfamily] (done) | time=2773ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=7ms
INFO: Sensor JavaScript analysis [javascript]
INFO: 45 source files to be analyzed
ERROR: Browserslist: caniuse-lite is outdated. Please run:
ERROR: npx browserslist@latest --update-db
ERROR: Why you should do it regularly:
INFO: 9/45 files analyzed, current file: src/Components/Screens/ContestScreen.js
INFO: 45/45 source files have been analyzed
INFO: Sensor JavaScript analysis [javascript] (done) | time=20479ms
INFO: Sensor TypeScript analysis [javascript]
INFO: Found 0 tsconfig.json file(s): []
ERROR: The 'files' list in config file 'tsconfig.json' is empty.
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor TypeScript analysis [javascript] (done) | time=855ms
INFO: Sensor JavaScript/TypeScript Coverage [javascript]
INFO: Analysing [/home/[hidden _abspath]/ProgettoSWE/twitter-client/coverage/]
WARN: Could not resolve 1 file paths in [/home/[hidden _abspath]/ProgettoSWE/twitter-client/coverage/]
WARN: First unresolved path: src/Components/Loading.js (Run in DEBUG mode to get full list of unresolved paths)
INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=48ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=1ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=4ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=2ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=12ms
INFO: CPD Executor 3 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 42 files
INFO: CPD Executor CPD calculation finished (done) | time=67ms
INFO: Analysis report generated in 92ms, dir size=451 KB
INFO: Analysis report compressed in 216ms, zip size=176 KB
INFO: Analysis report uploaded in 183ms
INFO: ANALYSIS SUCCESSFUL, you can browse https://[my_uni_server]/sonarqube/dashboard?id=team11-twitter-client
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://[my_uni_server]/sonarqube/api/ce/task?id=AX5zRfkw0cZOjy-gn5rQ
INFO: Analysis total time: 41.318 s
INFO: ------------------------------------------------------------------------
INFO: ------------------------------------------------------------------------
INFO: Total time: 43.854s
INFO: Final Memory: 13M/50M
INFO: ------------------------------------------------------------------------

Thanks again!

1 Like


Thanks for the analysis log. As a side note, I see that you’re on 8.9.0. You’re missing some security patches. You might mention to your school’s SonarQube admins that they need to upgrade to 8.9.6 at their earliest convenience. There aren’t any schema changes, so it should be painless.

Regarding the actual pain - coverage - I don’t much that’s pertinent that you didn’t already shared in your first post. So I did a little searching here in the community and found this advice in another thread:

You should make sure that all files mentioned in your coverage report are imported into SonarQube.

You mentioned that you kept the sonar.test.exclusion parameter because

I don’t see that parameter reflected in what you posted here. Is it possible you’ve accidentally excluded one or more covered files?

Also, I sense that a root of this problem is that the tests are located in a source directory. A fundamental assumption (inherited from the Maven-centric origins) of analysis is that source files and test files are separate things and are kept segregated. I don’t suppose you could move your test files out of src…?


sorry I didn’t answer to your reply earlier.

I can confirm that the files are imported into Sonarqube, since they can be accessed correctly in the Code section (as well as the Measures section). Regardless, the global coverage is still set to 0, as each file imported into Sonarqube shows a 0.0% coverage.

I also tried moving my test files (in the _ _ tests _ _ folder) out of both the src folder as well as out of the Components folder (but inside src). Still, nothing has change (aside from the directory structure of the files in Sonarqube).

About your sidenote: I will make sure to advise my school’s admins to update Sonarqube, thanks for your suggestion (and, in general, thanks helping me dealing with this).


1 Like


Okay, but what are they imported as? Code files or test files? The visual difference is subtle.



1 Like

Hi there,
the files are imported as what I assume are code files:


Hi Angelo,

So okay yes. Your code files are imported as code files. I’m out of my depth at this point, but the post is tagged to get the attention of more expert folks.

While we wait for them can you share full logs of your latest analysis, since you’ve changed some parameters?


1 Like