Skip to content

Code coverage exclusions are duplicated and risk drifting from Vitest configuration #10025

@Abderrahmane-MERSTANI

Description

@Abderrahmane-MERSTANI

Description
The list of files excluded from code coverage is manually defined in excludeFromCoverage and then injected into babel-plugin-istanbul.
This creates a risk of configuration drift if the same exclusions are also defined elsewhere (eg. in Vitest config), leading to inconsistent or misleading coverage reports.

Code concerned

export const excludeFromCoverage = [
'/node_modules/',
'/test//.js',
'/tests//
.js',
'/test-util/',
'/index.{ts,tsx}',
'
/login-forms.tsx',
'**/group-forms.tsx',
];

plugins: [
[
'babel-plugin-istanbul',
{
...vitestCoverageOptions,
exclude: excludeFromCoverage,
},
],
],

Problems

Coverage exclusion rules may be duplicated in multiple places

Easy for exclusions to get out of sync

Harder to maintain and reason about coverage accuracy

Contributors may update one config but forget the other

Expected Behavior

Coverage exclusions should be defined in one canonical place

Build and test tooling should reuse the same configuration

Suggested Fix

Export coverage exclusions from a shared config module

Or rely solely on vitestCoverageOptions and avoid redefining exclusions

{
...vitestCoverageOptions,
}

Impact

More accurate and predictable coverage reports

Reduced maintenance overhead

Cleaner build/test configuration

Better developer experience

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions