File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed
e2e/cli-e2e/tests/__snapshots__
packages/plugin-coverage/src/lib Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -147,11 +147,11 @@ exports[`CLI collect > should run Code coverage plugin and create report.json 1`
147147 " refs" : [
148148 {
149149 " slug" : " function-coverage" ,
150- " weight" : 1 ,
150+ " weight" : 6 ,
151151 },
152152 {
153153 " slug" : " branch-coverage" ,
154- " weight" : 1 ,
154+ " weight" : 3 ,
155155 },
156156 {
157157 " slug" : " line-coverage" ,
Original file line number Diff line number Diff line change @@ -3,9 +3,13 @@ import { fileURLToPath } from 'node:url';
33import type { Audit , Group , PluginConfig } from '@code-pushup/models' ;
44import { capitalize } from '@code-pushup/utils' ;
55import { name , version } from '../../package.json' ;
6- import { CoveragePluginConfig , coveragePluginConfigSchema } from './config' ;
6+ import {
7+ CoveragePluginConfig ,
8+ CoverageType ,
9+ coveragePluginConfigSchema ,
10+ } from './config' ;
711import { createRunnerConfig } from './runner' ;
8- import { coverageDescription } from './utils' ;
12+ import { coverageDescription , coverageTypeWeightMapper } from './utils' ;
913
1014/**
1115 * Instantiates Code PushUp code coverage plugin for core config.
@@ -42,7 +46,13 @@ export async function coveragePlugin(
4246 slug : 'coverage' ,
4347 title : 'Code coverage metrics' ,
4448 description : 'Group containing all defined coverage types as audits.' ,
45- refs : audits . map ( audit => ( { ...audit , weight : 1 } ) ) ,
49+ refs : audits . map ( audit => ( {
50+ ...audit ,
51+ weight :
52+ coverageTypeWeightMapper [
53+ audit . slug . slice ( 0 , audit . slug . indexOf ( '-' ) ) as CoverageType
54+ ] ,
55+ } ) ) ,
4656 } ;
4757
4858 const runnerScriptPath = join (
Original file line number Diff line number Diff line change @@ -22,3 +22,11 @@ export function applyMaxScoreAboveThreshold(
2222 output . score >= threshold ? { ...output , score : 1 } : output ,
2323 ) ;
2424}
25+
26+ /* eslint-disable no-magic-numbers */
27+ export const coverageTypeWeightMapper : Record < CoverageType , number > = {
28+ function : 6 ,
29+ branch : 3 ,
30+ line : 1 ,
31+ } ;
32+ /* eslint-enable no-magic-numbers */
You can’t perform that action at this time.
0 commit comments