Files
alfresco-ng2-components/lib/core/karma.conf.js
T
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

99 lines
4.8 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/@angular/material/prebuilt-themes/indigo-pink.css',
included: true,
watched: false
},
{ pattern: 'lib/core/src/lib/i18n/**/en.json', included: false, served: true, watched: false },
{ pattern: 'lib/core/**/*.ts', included: false, served: true, watched: false },
{ pattern: 'lib/core/src/lib/assets/**/*.svg', included: false, served: true, watched: false },
{ pattern: 'lib/core/src/lib/assets/**/*.png', included: false, served: true, watched: false },
{ pattern: 'lib/config/app.config.json', included: false, served: true, watched: false },
{ pattern: 'lib/core/src/lib/viewer/assets/fake-test-file.pdf', included: false, served: true, watched: false },
{ pattern: 'lib/core/src/lib/viewer/assets/fake-test-file.txt', included: false, served: true, watched: false },
{ pattern: 'lib/core/src/lib/viewer/assets/fake-test-video.mp4', included: false, served: true, watched: false },
{
pattern: 'lib/core//viewer/assets/fake-test-password-file.pdf',
included: false,
served: true,
watched: false
}
],
frameworks: ['jasmine'],
proxies: {
'/fake-url-file.png': '/base/lib/core/src/lib/assets/images/logo.svg',
'/logo.svg': '/base/lib/core/src/lib/assets/images/logo.svg',
'/alfresco-logo.svg': '/base/lib/core/src/lib/assets/images/alfresco-logo.svg',
'/assets/images/': '/base/lib/core/src/lib/assets/images/',
'/assets/images/ecm-background.png': '/base/lib/core/src/lib/assets/images/ecm-background.png',
'/assets/images/bpm-background.png': '/base/lib/core/src/lib/assets/images/bpm-background.png',
'/content.bin': '/base/lib/core/src/lib/viewer/assets/fake-test-file.pdf',
'/base/assets/': '/base/lib/core/src/lib/assets/',
'/assets/adf-core/i18n/en.json': '/base/lib/core/src/lib/i18n/en.json',
'/assets/adf-core/i18n/en-GB.json': '/base/lib/core/src/lib/i18n/en.json',
'/assets/adf-core/i18n/en-US.json': '/base/lib/core/src/lib/i18n/en.json',
'/fake-content-img': '/base/lib/core/src/lib/assets/images/logo.svg',
'/fake-content-img.bin': '/base/lib/core/src/lib/assets/images/logo.svg',
'/fake-test-file.pdf': '/base/lib/core/src/lib/viewer/assets/fake-test-file.pdf',
'/fake-content-pdf': '/base/lib/core/src/lib/viewer/assets/fake-test-file.pdf',
'/fake-content-pdf.bin': '/base/lib/core/src/lib/viewer/assets/fake-test-file.pdf',
'/fake-test-file.txt': '/base/lib/core/src/lib/viewer/assets/fake-test-file.txt',
'/fake-content-video.bin': '/base/lib/core/src/lib/viewer/assets/fake-test-video.mp4',
'/fake-content-video': '/base/lib/core/src/lib/viewer/assets/fake-test-video.mp4',
'/fake-content-txt.bin': '/base/lib/core/src/lib/viewer/assets/fake-test-file.txt',
'/fake-test-password-file.pdf': '/base/lib/core/src/lib/viewer/assets/fake-test-password-file.pdf'
},
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/core'),
subdir: '.',
reporters: [{ type: 'html' }, { type: 'lcov' }, { type: 'text-summary' }, { type: 'text-summary', subdir: '.', file: 'summary.txt' }],
check: {
global: {
statements: 75,
branches: 67,
functions: 70,
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';
};