TS coverage in a multi-modules project

  • Using Sonarqube Enterprise Edition Version 8.6.1 (build 40680)

  • I have a multi-module project. One module is in Java where i have the coverage right, One other is in Typescript where i don’t have the coverage yet.
    my lcov.info and ut_report.xml are correctly generated.

Here is my configuration
Parent module pom.xml:

<sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>

Typescript module pom.xml

<sonar.sources>src</sonar.sources>
<sonar.tests>src</sonar.tests>
<sonar.test.inclusions>/*.spec.ts</sonar.test.inclusions>
<sonar.testExecutionReportPaths>src/reports/ut_report.xml</sonar.testExecutionReportPaths>
<sonar.javascript.lcov.reportPath>src/coverage/lcov.info</sonar.javascript.lcov.reportPath>
<sonar.typescript.lcov.reportPath>src/coverage/lcov.info</sonar.typescript.lcov.reportPath>
<sonar.coverage.exclusions>
/*.spec.ts,karma.conf.js</sonar.coverage.exclusions>

package.json (3.0 KB) angular.json (4.1 KB)

karma.conf.js

// Karma configuration file, see link for more information
// Karma - Configuration File

process.env.CHROME_BIN = require(‘puppeteer’).executablePath()

module.exports = function (config) {
config.set({
basePath: ‘’,
frameworks: [‘jasmine’, ‘@angular-devkit/build-angular’],
plugins: [
require(‘karma-jasmine’),
require(‘karma-chrome-launcher’),
require(‘karma-jasmine-html-reporter’),
require(‘karma-coverage-istanbul-reporter’),
require(’@angular-devkit/build-angular/plugins/karma’),
require(‘karma-sonarqube-unit-reporter’)
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
jasmine: {
random : false,
oneFailurePerSpec: true
}
},
coverageIstanbulReporter: {
dir: require(‘path’).join(__dirname, ‘coverage’),
reports: [‘html’, ‘lcovonly’, ‘text-summary’],
fixWebpackSourcePaths: true
},
sonarQubeUnitReporter: {
sonarQubeVersion: ‘LATEST’,
outputFile: ‘reports/ut_report.xml’,
useBrowserName: false
},
reporters: [‘progress’, ‘sonarqubeUnit’, ‘kjhtml’],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: [‘Chrome’],
customLaunchers: {
FirefoxHeadless: {
base: ‘Firefox’,
flags: [ ‘-headless’ ],
},
ChromeHeadlessNoSandbox: {
base: ‘ChromeHeadless’,
flags: [’–no-sandbox’]
}
},
singleRun: false,
browserDisconnectTimeout : 10000,
browserDisconnectTolerance : 1,
browserNoActivityTimeout : 60000
});
};

Hello @wokier,

Welcome to SonarSource community, and thank you for your message !

First of all, I would like to apologize for answering this late. Coming back to your problem, and looking at your pom.xml, it seems that there is a typo in your coverage-related properties. Indeed, you should use the plural form of the properties: sonar.javascript.lcov.reportPaths and sonar.typescript.lcov.reportPaths.

Hope this helps,
Yassin

1 Like

Thanks a lot, indeed it solved my issue.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.