test(coverage): enforce an 80% c8 floor and cover the CLI surface (#85) - #94
Open
robotlearning123 wants to merge 3 commits into
Open
robotlearning123 wants to merge 3 commits into
robotlearning123 wants to merge 3 commits into
Conversation
… point
Add .c8rc.json with all:true so unloaded modules appear in the report, and
fail test:coverage below 80% lines/functions. Add in-process tests for
src/commands/{check,init}.ts and a tsx-spawned test for src/index.ts so the
CLI surface is measured without requiring a build.
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.
What
Closes #85.
test:coveragehad no threshold, so it always exited 0.src/commands/*andsrc/index.tsnever appeared in the report because no test loaded them..c8rc.json:all: true, so unloaded src files show as 0% instead of disappearing.check-coveragewithlines: 80andfunctions: 80.src/types.ts(interfaces),src/lib.ts, the pure re-export barrelssrc/engine/index.tsandsrc/utils/index.ts, and*.d.ts.src/index.ts(CLI entry) andsrc/templates/index.ts(template loader) stay inside the gate.test/commands.test.ts:checkCommandandinitCommand, with console andprocess.exitstubbed. They cover human and--jsonoutput,--strictexit 1, the error branch,--dry-run,--check,--force, template substitution, an invalidpackage.json, and a write failure.tsx-spawned tests forsrc/index.tsrouting.src/index.tsandsrc/templates/index.tsare never excluded.package.jsonis not modified. The threshold lives in.c8rc.json, so it does not collide with deps: bump c8 from 10.1.3 to 11.0.0 #55 (c8 10->11) or fix(test): include test/e2e in test globs and build before tests #90 (e2e test globs).Evidence (this branch)
npm run test:coverageexits 0, with nosrc/commands/src/index.tsrowsERROR: Coverage for lines (65.74%) does not meet global threshold (80%), exit 1npm run checkgreentest/commands.test.tsgives exit 1Sequencing
origin/maine704b49. This PR does not depend on fix(test): include test/e2e in test globs and build before tests #90 or deps: bump c8 from 10.1.3 to 11.0.0 #55..c8rc.jsonuses standard c8 options. They were run with c8 10 only; after deps: bump c8 from 10.1.3 to 11.0.0 #55 lands, re-runnpm run test:coverage.npm test. When fix(test): include test/e2e in test globs and build before tests #90 lands, coverage can only rise, so re-measure the floor then.npm test, nottest:coverage, so the floor is not yet enforced in CI. That is a CI change left for an owner decision.Review
src/**/index.tsalso matchedsrc/index.ts. It was fixed in e608f76, and the delta re-review said SHIP.src/*/index.tsstill hidsrc/templates/index.ts. That was fixed in 72f4634, with a test that fails first.path.matchesGlob, which needs Node >= 20.17 / 22.5. CI's20.x/22.xresolve to recent releases.