test: run CLI entry tests in-process so V8 coverage attributes them - #65
Merged
Conversation
Mirrors the design landed in putdotio/taizn#62. Vitest 4 cannot attribute V8 coverage from spawned subprocesses (coverage.autoAttachSubprocess lands in vitest 5), and NODE_V8_COVERAGE plumbing plus bundle remapping is disproportionate machinery. rokit's mainEffect(argv) was already importable, so the completions and usage-error spawn tests now run it in-process with console spies; only the boot test still spawns the packaged binary, and that blind spot (the src/rokit.ts shim, already excluded) is documented in vite.config.ts and AGENTS.md. Coverage: statements 65.91->68.96, branches 53.42->55.88, functions 57.86->60.73, lines 65.83->68.73 (same denominators). Floors raised 63/51/55/63 -> 66/53/58/66. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR restructures CLI entrypoint tests to run in-process (instead of spawning the built CLI) so V8 coverage correctly attributes executed code, addressing the subprocess coverage blind spot described in #63 and aligning with the sibling design referenced in the PR description.
Changes:
- Updated CLI tests to call
mainEffect(argv)in-process with console spies for cases where the subprocess boundary is not under test. - Documented the remaining subprocess coverage blind spot (boot test still spawns
dist/rokit.mjs) invite.config.tsandAGENTS.md, with a pointer to Vitest 5’scoverage.autoAttachSubprocess. - Raised V8 coverage thresholds to match the new measured baseline (with headroom).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| vite.config.ts | Documents the subprocess coverage limitation and raises coverage thresholds to the new baseline. |
| test/cli.test.ts | Introduces an in-process CLI runner for coverage-attributed tests while keeping a spawn-based boot test. |
| AGENTS.md | Captures the testing/coverage approach as a repo “Sharp Edges” guidance note for contributors. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
|
🎉 This PR is included in version 2.4.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #63. Mirrors the design from the sibling issue, landed in putdotio/taizn#62 (one design, two applications): subprocess-spawned CLI tests execute real code V8 coverage never attributes, understating the floor set in #61.
Design decision (shared): no released vitest can attribute subprocess coverage — vitest 4.1.10/4.1.11 has zero
NODE_V8_COVERAGEhandling;coverage.autoAttachSubprocessexists only in unreleased Vitest 5.0. ManualNODE_V8_COVERAGEplumbing + sourcemapped bundle remapping through a custom coverage provider is disproportionate machinery. So spawn-based tests were restructured to run the same entry in-process where the subprocess boundary isn't the thing under test.Changed
--completionsand the package usage-error tests now runmainEffect(argv)in-process with console spies (rokit's entry was already importable and argv-parameterized, so no source changes were needed).dist/rokit.mjs— the process boundary is the thing under test there. That blind spot (thesrc/rokit.tsshim, already excluded from coverage) is now documented invite.config.tsand AGENTS.md with the vitest 5 pointer.Risks
Low: test-only change plus threshold/doc updates. The in-process harness restores
process.exitCodeand console spies in afinally.Verification
vp run verifygreen (check, skillcheck lint, typecheck, pack, smoke, coverage thresholds, npm pack).Coverage delta (
vp test run --coverage, same denominators):Follow-Ups
When vite-plus ships vitest 5, enable
coverage.autoAttachSubprocessand re-measure to close the boot-test blind spot (same follow-up as taizn).