Files
alfresco-ng2-components/lib/process-services/karma.conf.js
7b8d616a9f AAE-50678 Fix: report test coverage to SonarCloud (#12181),
* fix: enable LCOV coverage reporting for SonarCloud

Add lcov reporter to all karma configs, upload coverage artifacts from
unit test matrix jobs, and add a SonarCloud scan job that merges
coverage reports and runs the sonar-scanner with proper LCOV paths.

Co-authored-by: eromano <1030050+eromano@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix: pass secrets to unit-test-workflow and set SONAR_HOST_URL for SonarCloud

Co-authored-by: eromano <1030050+eromano@users.noreply.github.com>

* fix: add test outputs to nx.json so NX caches and restores coverage reports

Co-authored-by: eromano <1030050+eromano@users.noreply.github.com>

* test: add unit tests for Chart model to verify coverage reporting

* fix: use find to locate lcov.info in downloaded artifacts for SonarCloud coverage

Co-authored-by: eromano <1030050+eromano@users.noreply.github.com>

* test: add fake file with unit test to verify coverage reporting

Co-authored-by: eromano <1030050+eromano@users.noreply.github.com>

* ci: add full SonarCloud scan workflow on develop push

Co-authored-by: eromano <1030050+eromano@users.noreply.github.com>

* test: remove fake coverage-canary file and its spec

Co-authored-by: eromano <1030050+eromano@users.noreply.github.com>

* fix: replace secrets inherit with explicit SONAR_TOKEN in workflow call

Co-authored-by: eromano <1030050+eromano@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: eromano <1030050+eromano@users.noreply.github.com>
Co-authored-by: Eugenio Romano <eromano@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-08-19 19:44:15 +02:00

73 lines
3.2 KiB
JavaScript

// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
/* eslint-env es6 */
const { join } = require('path');
const { constants } = require('karma');
module.exports = function (config) {
config.set({
basePath: '../../',
files: [
{ pattern: 'node_modules/pdfjs-dist/build/pdf.min.mjs', type: 'module', included: true, watched: false },
{ pattern: 'node_modules/pdfjs-dist/build/pdf.worker.min.mjs', type: 'module', included: true, watched: false },
{
pattern: 'node_modules/@angular/material/prebuilt-themes/indigo-pink.css',
included: true,
watched: false
},
{ pattern: 'node_modules/raphael/raphael.min.js', included: true, watched: false },
{ pattern: 'lib/core/src/lib/i18n/**/en.json', included: false, served: true, watched: false },
{ pattern: 'lib/content-services/src/lib/i18n/**/en.json', included: false, served: true, watched: false },
{ pattern: 'lib/process-services/src/lib/i18n/**/en.json', included: false, served: true, watched: false },
{ pattern: 'lib/process-services/**/*.ts', included: false, served: true, watched: false },
{ pattern: 'lib/config/app.config.json', included: false, served: true, watched: false }
],
frameworks: ['jasmine'],
proxies: {
'/assets/': '/base/lib/process-services/src/lib/assets/',
'/assets/adf-core/i18n/en.json': '/base/lib/core/src/lib/i18n/en.json',
'/assets/adf-content-services/i18n/en.json': '/base/lib/content-services/src/lib/i18n/en.json',
'/assets/adf-process-services/i18n/en-GB.json': '/base/lib/process-services/src/lib/i18n/en.json',
'/app.config.json': '/base/lib/config/app.config.json'
},
plugins: [require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage')],
client: {
clearContext: false,
jasmine: {
random: false
}
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: join(__dirname, '../../coverage/process-services'),
subdir: '.',
reporters: [{ type: 'html' }, { type: 'lcov' }, { type: 'text-summary' }, { type: 'text-summary', subdir: '.', file: 'summary.txt' }],
check: {
global: {
statements: 75,
branches: 67,
functions: 65,
lines: 75
}
}
},
customLaunchers: {
ChromeHeadless: {
base: 'Chrome',
flags: ['--no-sandbox', '--headless', '--disable-gpu', '--remote-debugging-port=9222']
}
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: constants.LOG_INFO,
browsers: ['ChromeHeadless'],
singleRun: true
});
process.env.TZ = 'UTC';
};