hypothesis / hypothesis/h

Code coverage exclusions are duplicated and risk drifting from Vitest configuration

Open
#10,025 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
3.2k
Forks
459
Avg merge
27d 1h
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.