Skip to content

Drop Codecov and set coverage thresholds in Vitest - #4238

Merged
nstepien merged 7 commits into
mainfrom
drop-codecov
Nov 1, 2026
Merged

nstepien merged 7 commits into
mainfrom
drop-codecov

Conversation

@nstepien

@nstepien nstepien commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Codecov's status check was informational, so it never blocked a PR. This removes Codecov entirely: the upload step, .github/codecov.yml, and the README badge. Instead, Vitest fails the test run when coverage drops below coverage.thresholds. Coverage is still only collected in the CI workflow, or with --coverage, so other vp test runs are unaffected.

The thresholds are the current coverage, rounded down:

Coverage Threshold
Branches 95.29–95.39% 95%
Lines 99.22–99.28% 99%

statements and functions have no threshold. With each file and function in src/ in turn losing all its coverage, branches and lines failed on every case that any threshold failed on, while statements and functions never failed without lines also failing. This only simulates one file or function at a time.

CI, which also runs the visual tests, reports about the same coverage as local runs, within 0.1 points. Branch coverage varied slightly over six local runs: a couple of branches depend on timing, e.g., in useScrollState, and even the total number of branches varied (2022–2027). lines has the least headroom, about 0.2%, or four lines, against about 0.3%, or seven branches, for branches.

The json reporter only fed Codecov. It's replaced by a text table of the files that aren't fully covered, with their uncovered lines, so CI's log shows what lacks coverage when a threshold fails. maxCols: 0 keeps file names whole: without a terminal, the table is truncated to 80 columns (e.g., ...eaderCell.tsx).

AGENTS.md now says to validate with vp run ci --coverage, which also checks the thresholds.

The coverage directory

With no reporter writing files, Vitest deletes the empty coverage directory after the run (cleanAfterRun), so CI no longer creates it upfront. Vite Task records directory listings after the run, so creating it beforehand would make the test task miss the cache every time. Locally, with the coverage settings of CI, a second vp run test replayed the cache, and a third one, after mkdir coverage, missed with "'coverage' added in workspace root".

Alternatives

  • Collecting coverage in vp run test, e.g., with vp test --coverage as the task's command, would let vp run ci check the thresholds without the --coverage flag, while vp test <files> stays unaffected. Locally, the full suite took 33–41 s with coverage, against 30–32 s without.
  • Thresholds as counts (negative numbers set the maximum number of uncovered items) would fail on any new uncovered code, rather than on a lower percentage.
  • thresholds.autoUpdate raises the thresholds when coverage exceeds them, but does so by rewriting vite.config.ts after a full run.
  • GitHub Code Quality's coverage needs a paid Code Quality license for the organization, can't upload coverage from fork PRs, and only keeps the latest upload of each branch.

After merging

The CODECOV_TOKEN secret, and the Codecov app's access to the repository, can be removed.

vp run typecheck, vp check, vp run eslint, vp pack, and vp build pass, and so does the full suite with coverage enabled, locally and in CI.

🤖 Generated with Claude Code

nstepien and others added 6 commits October 26, 2026 00:56
CI no longer uploads coverage to Codecov. Instead, Vitest fails the run
when coverage drops below `coverage.thresholds`, and lists the files
that aren't fully covered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@nstepien
nstepien marked this pull request as ready for review November 1, 2026 01:18
@nstepien
nstepien merged commit ecd76d3 into main Nov 1, 2026
6 checks passed
@nstepien
nstepien deleted the drop-codecov branch November 1, 2026 01:22
@nstepien

nstepien commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

Merging this.
No one looks at the coverage result details, and the codecov comments are more annoying/distracting than useful.
Most repos don't showcase their coverage status either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant