Add possibility to create coverage reports (#9029)

This commit is contained in:
Florian Bischof
2023-07-15 15:23:44 +02:00
committed by GitHub
parent 084f5d9b7c
commit 854f71da03
4 changed files with 919 additions and 19 deletions

View File

@ -9,6 +9,7 @@ module.exports = {
'docs/examples/extending/extending-2-layers.md',
'docs/_posts/201*',
'docs/_site',
'coverage'
],
root: true,
globals: {

910
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,9 +12,11 @@
"eslint-plugin-import": "^2.27.5",
"http-server": "^14.1.1",
"husky": "^8.0.1",
"istanbul": "^0.4.5",
"karma": "^6.4.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.1",
"karma-coverage": "^2.2.1",
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-safarinative-launcher": "^1.1.0",
@ -46,6 +48,7 @@
"debug": "http-server -c-1",
"docs": "node ./build/docs.mjs && node ./build/integrity.mjs",
"test": "karma start ./spec/karma.conf.js",
"coverage": "karma start ./spec/karma.conf.js --coverage --single-run",
"build": "npm run rollup && npm run uglify",
"lint": "eslint . --ext js,mjs,cjs",
"lintfix": "npm run lint -- --fix",

View File

@ -1,6 +1,9 @@
/* eslint-env node */
// See: https://karma-runner.github.io/latest/config/configuration-file.html
module.exports = function (/** @type {import('karma').Config} */ config) {
config.set({
const isCoverageEnabled = process.argv.includes('--coverage');
const karmaConfig = {
basePath: '../',
plugins: [
'karma-mocha',
@ -24,6 +27,13 @@ module.exports = function (/** @type {import('karma').Config} */ config) {
{pattern: 'dist/*.css', type: 'css'},
],
reporters: ['progress', 'time-stats'],
coverageReporter: {
dir: 'coverage/',
reporters: [
{type: 'html', subdir: 'html'},
{type: 'text-summary'}
]
},
timeStatsReporter: {
reportTimeStats: false,
longestTestsCount: 10
@ -64,5 +74,15 @@ module.exports = function (/** @type {import('karma').Config} */ config) {
forbidOnly: process.env.CI || false
}
}
});
};
if (isCoverageEnabled) {
karmaConfig.plugins.push('karma-coverage');
karmaConfig.reporters.push('coverage');
karmaConfig.preprocessors = {
'dist/leaflet-src.esm.js': 'coverage'
};
}
config.set(karmaConfig);
};