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/examples/extending/extending-2-layers.md',
'docs/_posts/201*', 'docs/_posts/201*',
'docs/_site', 'docs/_site',
'coverage'
], ],
root: true, root: true,
globals: { 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", "eslint-plugin-import": "^2.27.5",
"http-server": "^14.1.1", "http-server": "^14.1.1",
"husky": "^8.0.1", "husky": "^8.0.1",
"istanbul": "^0.4.5",
"karma": "^6.4.1", "karma": "^6.4.1",
"karma-chai": "^0.1.0", "karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.1", "karma-chrome-launcher": "^3.1.1",
"karma-coverage": "^2.2.1",
"karma-firefox-launcher": "^2.1.2", "karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1", "karma-mocha": "^2.0.1",
"karma-safarinative-launcher": "^1.1.0", "karma-safarinative-launcher": "^1.1.0",
@ -46,6 +48,7 @@
"debug": "http-server -c-1", "debug": "http-server -c-1",
"docs": "node ./build/docs.mjs && node ./build/integrity.mjs", "docs": "node ./build/docs.mjs && node ./build/integrity.mjs",
"test": "karma start ./spec/karma.conf.js", "test": "karma start ./spec/karma.conf.js",
"coverage": "karma start ./spec/karma.conf.js --coverage --single-run",
"build": "npm run rollup && npm run uglify", "build": "npm run rollup && npm run uglify",
"lint": "eslint . --ext js,mjs,cjs", "lint": "eslint . --ext js,mjs,cjs",
"lintfix": "npm run lint -- --fix", "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 // See: https://karma-runner.github.io/latest/config/configuration-file.html
module.exports = function (/** @type {import('karma').Config} */ config) { module.exports = function (/** @type {import('karma').Config} */ config) {
config.set({ const isCoverageEnabled = process.argv.includes('--coverage');
const karmaConfig = {
basePath: '../', basePath: '../',
plugins: [ plugins: [
'karma-mocha', 'karma-mocha',
@ -24,6 +27,13 @@ module.exports = function (/** @type {import('karma').Config} */ config) {
{pattern: 'dist/*.css', type: 'css'}, {pattern: 'dist/*.css', type: 'css'},
], ],
reporters: ['progress', 'time-stats'], reporters: ['progress', 'time-stats'],
coverageReporter: {
dir: 'coverage/',
reporters: [
{type: 'html', subdir: 'html'},
{type: 'text-summary'}
]
},
timeStatsReporter: { timeStatsReporter: {
reportTimeStats: false, reportTimeStats: false,
longestTestsCount: 10 longestTestsCount: 10
@ -64,5 +74,15 @@ module.exports = function (/** @type {import('karma').Config} */ config) {
forbidOnly: process.env.CI || false 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);
}; };