Skip to content

test: raise unit coverage to ~99.9% and enforce thresholds#64

Merged
Bccorb merged 1 commit into
feat/coverage-badgefrom
test/coverage-push
Jul 17, 2026
Merged

test: raise unit coverage to ~99.9% and enforce thresholds#64
Bccorb merged 1 commit into
feat/coverage-badgefrom
test/coverage-push

Conversation

@Bccorb

@Bccorb Bccorb commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

A large testing push that takes CLI unit coverage from 23.2% to 99.9% lines, then adds Vitest coverage thresholds so the level is enforced going forward.

Stacked on top of #63 (the coverage-badge PR); this PR is targeted at that branch so the diff is only the test work. Merge #63 first, or retarget to main after it lands.

Coverage

Metric Before After
Lines 23.2% 99.88%
Statements 23.2% 99.88%
Functions - 99.61%
Branches - 96.92%

552 tests (548 passing, 4 pre-existing skipped e2e). 44 new/updated *.test.ts files covering every command, core module, generator, prompt, util, and the entry dispatcher.

Approach

  • Tests are co-located *.test.ts and follow the repo's existing dependency-injection style (e.g. setBackendForTesting, injected clients/fetch, the fakeClient pattern).
  • External boundaries are mocked without touching source: @clack/prompts, fs, child_process, network (fetch), @napi-rs/keyring, and adm-zip (via real in-memory zip fixtures).
  • Command tests spy process.exit (throw-to-short-circuit) and assert user-facing output, request shapes, and exit codes.
  • src/index.ts (which runs main() at import) is tested by mocking every command module and re-importing per argv scenario with vi.resetModules().
  • No source files were modified anywhere in this PR: it is test-only plus the vitest.config.ts threshold block.

Thresholds (the enforced "limits")

Added to vitest.config.ts, set just below current numbers as a regression floor:

thresholds: { lines: 99, statements: 99, functions: 99, branches: 95 }

npm run coverage (and therefore the pre-commit hook from #63) now fails if coverage drops below these.

Remaining uncovered (7 lines)

All are genuinely unreachable branches, documented rather than papered over:

  • src/generators/docker/docker.ts (5 lines): a private multiline-env helper; values reaching it come from parseEnvString/secret generators and can never contain a newline.
  • The remaining branch gaps are ??/optional-chaining default operands whose lines are fully covered.

Checks

  • npm run coverage passes with thresholds enforced (exit 0)
  • npm run build passes
  • Pre-commit hook ran on this commit and regenerated the badge (now 99.9%)

Add unit tests across the CLI (commands, core, generators, prompts, utils,
and the entry dispatcher), bringing line coverage from 23% to 99.9%. Tests
are co-located *.test.ts, follow the repo's dependency-injection style, and
mock external boundaries (@clack/prompts, fs, child_process, network, keyring)
without changing any source.

Add Vitest coverage thresholds (lines/statements 99, functions 99, branches 95)
as a regression floor. The remaining uncovered lines are unreachable branches
(a private multiline-env helper in the docker generator).
@Bccorb
Bccorb merged commit 300a7fa into feat/coverage-badge Jul 17, 2026
1 check failed
@Bccorb
Bccorb deleted the test/coverage-push branch July 17, 2026 03:23
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