Skip to content

test: Vitest coverage infra + backfill to 85% coverage mandate - #56

Merged
Wikid82 merged 1 commit into
mainfrom
feature/vitest-codecov-coverage
Aug 10, 2026
Merged

test: Vitest coverage infra + backfill to 85% coverage mandate#56
Wikid82 merged 1 commit into
mainfrom
feature/vitest-codecov-coverage

Conversation

@Wikid82

@Wikid82 Wikid82 commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds Vitest + React Testing Library, replacing the node:test runner. Server/action/lib tests run in plain Node (jose's Uint8Array checks break under jsdom's separate realm); component tests opt into jsdom per-file via a // @vitest-environment jsdom docblock.
  • Adds codecov.yml + .github/workflows/codecov.yml gating project and patch coverage at 85%, mirroring the Charon setup. ci.yml's test step now runs npm run test:coverage so the 85% floor is enforced even before the Codecov GitHub App/secret are wired up on this repo.
  • Adds scripts/check-patch-coverage.mjs (npm run coverage:patch) — a dependency-free Node script that diffs coverage/lcov.info against a git baseline to report patch coverage locally, plus .claude/commands/fix-patch-coverage.md (Hestia's equivalent of Charon's /fix-patch-coverage) to close gaps before pushing.
  • Backfills real unit/component tests for the previously-untested action layer (chores, rewards, reminders, members, household, profile, auth), auth/session.ts, auth/current-user.ts, proxy.ts, and 16 components. Real coverage goes from ~12% to 99.4% lines / 90.6% branches / 100% functions.
  • Server-logic tests run against a real in-memory SQLite DB (migrated fresh per test file) with next/headers, next/cache, and next/navigation mocked in src/test/setup.tsredirect() throws Error("NEXT_REDIRECT:<path>"), asserted on directly rather than mocked away.
  • page.tsx/layout.tsx route entrypoints, db/schema.ts, db/index.ts, and instrumentation.ts are excluded from the coverage mandate (thin composition/declarative/bootstrap code, exercised by e2e/household-flow.spec.ts instead) — same ignore list in codecov.yml, vitest.config.ts, and the patch-coverage script.

Note on workflow files: this PR includes changes to .github/workflows/ci.yml and adds .github/workflows/codecov.yml, rather than committing those straight to main per the repo's usual convention. They depend on the accompanying package.json/vitest.config.ts changes in this same PR — landing them on main first would break main's CI until this merges down through development. Flagging this explicitly since it's a deviation from the documented workflow-files-go-to-main rule.

Still needed from a maintainer (can't be done from here): install the Codecov GitHub App on this repo and add a CODECOV_TOKEN repository secret for .github/workflows/codecov.yml to actually upload — until then, the codecov job will fail at the upload step (tests/coverage/build all still pass regardless).

Test plan

  • npm run test:coverage — 172 tests pass, 99.41% lines / 90.61% branches / 100% functions / 99.09% statements (threshold: 85% lines)
  • npm run lint — clean
  • npm run build — clean, TypeScript passes
  • node scripts/check-patch-coverage.mjs — manually verified it correctly flags an uncovered synthetic change and correctly reports clean when reverted
  • Install Codecov GitHub App + add CODECOV_TOKEN secret (maintainer action, see note above)

🤖 Generated with Claude Code

Adds Vitest + React Testing Library (replacing the node:test runner),
a codecov.yml/GitHub workflow enforcing 85% project+patch coverage,
and a local scripts/check-patch-coverage.mjs + /fix-patch-coverage
command so patch-coverage gaps can be caught before pushing instead
of failing CI. Backfills unit/component tests for the previously
untested action layer, auth/session logic, proxy, and 16 components
to bring real coverage from ~12% to 99.4% lines / 90.6% branches.

Bundles the .github/workflows/ci.yml and codecov.yml workflow changes
into this PR (rather than committing them straight to main per the
usual CI-file convention) because they depend on the accompanying
package.json/vitest.config.ts changes — landing them on main first
would break main's CI until this PR merges down through development.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@Wikid82
Wikid82 changed the base branch from development to main August 10, 2026 16:55
@Wikid82
Wikid82 merged commit 4eba452 into main Aug 10, 2026
19 of 20 checks passed
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.

2 participants