No coverage information will be saved because all LCOV files cannot be found

  • SonarQube Enterprise 9.7.1, SonarScanner CLI v4.6.1.2450
  • We are trying to scan a Ext.JS project tests and provide code coverage reports
  • We’re using karma and jasmine
  • We are running SonarScanner CLI with the following property:
/d:sonar.javascript.lcov.reportPaths=./TestResults/coverage/lcov.info
  • We tried this too and had the same issue:
/d:sonar.javascript.lcov.reportPaths=TestResults/coverage/lcov.info
  • Issue:

[2022-11-24T13:48:36.994Z] 08:48:36.929 INFO: Sensor JavaScript/TypeScript Coverage [javascript]
[2022-11-24T13:48:36.994Z] 08:48:36.930 DEBUG: Property sonar.javascript.lcov.reportPaths is used.
[2022-11-24T13:48:36.994Z] 08:48:36.930 DEBUG: Using './TestResults/coverage/lcov.info' to resolve LCOV files
[2022-11-24T13:48:36.994Z] 08:48:36.959 INFO: No LCOV files were found using ./TestResults/coverage/lcov.info
[2022-11-24T13:48:36.994Z] 08:48:36.959 WARN: No coverage information will be saved because all LCOV files cannot be found.
[2022-11-24T13:48:36.994Z] 08:48:36.959 INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=30ms

Our karma.conf.js:

module.exports = function(config) {
  config.set({

    basePath: '',

    frameworks: ['jasmine'],

    plugins : [
        'karma-jasmine',
        'karma-phantomjs-launcher',
        'karma-coverage',
        'karma-junit-reporter'
    ],

    files: [
        'ext/build/ext-modern-all-debug.js',
        'setup-karma.js',

        { pattern: 'ext/**/*.*', watched: false, served: true, included: false},
        { pattern: 'app/**/*.js', watched: true, served: true, included: true },
        { pattern: 'specs/**/*.js', watched: false, served: true, included: true },
    ],

    // for now we're ignoring these files
    exclude: ['specs/model/*Spec.js',
                'specs/model/*Spec.js',
                'specs/model/*Spec.js',
                'specs/store/*Spec.js',
                'specs/store/*Spec.js'
    ],

    preprocessors: {
      'app/**/*.js': ['coverage'],
      'overrides/*.js': ['coverage']
    },

    reporters: ['junit', 'coverage', 'progress'],

    port: 9876,

    colors: true,

    logLevel: config.LOG_INFO,

    autoWatch: true,

    browsers: ['PhantomJS'],

    singleRun: true,

    concurrency: Infinity,

    captureTimeout : 60000,
    browserDisconnectTimeout : 60000,
    browserNoActivityTimeout : 60000,

    junitReporter: {
      outputDir: '../TestResults',
      suite: 'models',
      useBrowserName: false,
      xmlVersion: '1'
    },

    coverageReporter: {
      type: 'lcov',
      dir: '../TestResults/coverage',
      subdir: '.'
    },
  });
};

The project structure:

--root
  |---TestResults
  |    |----coverage
  |    |     |-----lcov.info
  |---Mobile.Ext
  |    |----apps // js files
  |    |----specs // tests
  |    |----karma.conf.js

The weirdest thing is that the lcov.info file exists on the folder when SonarScanner starts to run.

Any help would be greatly appreciated! Thank you in advance!

Hey there.

What directory are you initiating the SonarQube scan from? The root directory?

This will be the correct format.

Hi there!

Yeah, the SonarQube scan is been executed on the root directory. The sonar.sources is going through all the directories on the project.

Hey there.

Thanks.

I would suggest two things:

  • Supply the complete analysis logs (redacting sensitive info if necessary).
  • Not knowing the full details of your build, you might try printing the content of TestResults/coverage/lcov.info immediately before the scanner, just to be extra sure it exists at the right time. Something like cat TestResults/coverage/lcov.info