Repository navigation
fix(coverage): include core/ files in v8 per-file gate (#1301) - #1305
Conversation
Two issues prevented coverage.include's '../../core/...' globs from reaching core/ files: 1. allowExternal defaults to false — v8 drops any file whose absolute path doesn't start with the project root (clients/web/) before the include filter runs. Set allowExternal: true, and switch the globs to absolute paths so tinyglobby + picomatch handle them correctly. 2. vitest's coverage transformer only processes files inside a project root; for everything else it falls back to raw-TS parsing in rolldown, which can't handle TS-only syntax (e.g. import type) — silently dropping untested core/ files and bypassing the gate. Root the unit project at the repo root so the transformer reaches core/. The repo root has no node_modules, so add an explicit react alias and shift include/setupFiles paths accordingly. Also add the four pure-type core files (samplingCreateMessage, sessionStorage, inspectorClientProtocol, inspectorClientEventTarget) to the exclude list with a comment — they have no executable code. Verified by introducing an untested probe file, confirming exit=1 with threshold errors, then removing it. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
@claude review |
|
Claude finished @cliffhall's task in 1m 39s —— View job Code Review
OverallSolid, well-explained fix. The PR description accurately diagnoses both issues (default Verified claims
Nits / follow-ups1. Duplicate Vitest projects don't merge 2. Is Once the unit project's root is 3. The empty-body class will stop being "0 statements" the moment any method or field body is added (the v1.5 port in #1243 mentions more surface landing later). Consider a Questions (non-blocking)
Nothing blocking — recommend merge after the two comment-level nits above, whichever you prefer to action. The coverage gate is now actually doing what it says on the tin for |
- Drop allowExternal: true — with the unit project rooted at repoRoot, core/ files are no longer "external" to any project that collects coverage (the storybook project doesn't), so the flag is redundant. - Extract sharedAliases / sharedDedupe constants and reference them from both the top-level resolve and the unit project resolve, so the two stay in sync if a new core/* alias is added. - Add TODO(#1243) on the inspectorClientEventTarget.ts exclusion so it's revisited once the class gains real behavior in the InspectorClient port. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Thanks for the careful review @claude — pushed 161e9c9 addressing all three. 1. Duplicate 2. Is 3. On the question about Validate + storybook both still green (937 + 298 tests). |
|
Claude finished @cliffhall's task in 37s —— View job Follow-up review — 161e9c9All three items land cleanly. Quick verification pass: 1. Shared alias/dedupe extraction ( 2. 3. On Nothing further from me — LGTM, ready to merge. Coverage gate now actually gates
|
Summary
Fixes #1301. Two distinct problems were preventing
coverage.include's../../core/**globs from actually measuring files undercore/:allowExternal: false(the default) — vitest drops any file whose absolute path doesn't start with the project root (clients/web/) before applying the include filter. The../../core/...globs never had a chance to match.getSourcesfalls back to reading the raw.tsfile and feeding it to rolldown's parser, which can't handle TS-only syntax likeimport type {…}. Untested core files were being silently dropped viaFailed to parse … Excluding it from coverage— bypassing the per-file gate.Fixes in
clients/web/vite.config.ts:coverage.allowExternal: trueand rewrite the cross-package globs as absolute paths so both tinyglobby (used bygetUntestedFiles) and picomatch (used byisIncluded) match correctly.core/. Adjustinclude/setupFilespaths and add an explicitreactalias (the repo root has nonode_modules/of its own to walk up to).samplingCreateMessage,sessionStorage,inspectorClientProtocol,inspectorClientEventTarget) with a comment — they have no executable code, mirroring the existing exclusions fortypes.ts/elicitationCreateMessage.ts.Verification
coverage-summary.jsonnow contains 31 entries undercore/mcp/andcore/react/(was 0).core/mcp/__coverageProbe.tswith one untested function —npm run test:coverageexited with code 1 and emitted fourERROR: Coverage for X (0%) does not meet global threshold (Y%) for ../../core/mcp/__coverageProbe.tslines. Removed afterwards.Test plan
npm run validate(format, lint, build, test:coverage) passes — exit 0npm run test:storybookpasses — 298 tests across 67 files🤖 Generated with Claude Code