aboutsummaryrefslogtreecommitdiff
path: root/languages/typescript/claude/rules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-31 13:57:40 -0500
committerCraig Jennings <c@cjennings.net>2026-05-31 13:57:40 -0500
commitee903e4b63257573773e93d10612250e3634cae9 (patch)
tree89cc6199b53f445a4c32252c6b982a6c86964e3b /languages/typescript/claude/rules
parent47ca509e69b6a1472a735a4b9521a952e7434491 (diff)
downloadrulesets-ee903e4b63257573773e93d10612250e3634cae9.tar.gz
rulesets-ee903e4b63257573773e93d10612250e3634cae9.zip
feat(typescript): add coverage-summary to the TypeScript bundle
Last language in the coverage-summary fan-out, after Elisp, Python, and Go. Same kernel: count every source file on disk that's absent from the coverage report as 0% and weight the project number by file, so an untested file stays visible instead of being averaged away. The script at languages/typescript/claude/scripts/coverage-summary.js parses an Istanbul json-summary report (the coverage-summary.json that c8, Vitest, and Jest all emit), takes per-file statements covered over total, and reports a file-weighted number plus the missing files. It walks the source dir for .ts/.js, skipping test files, declarations, and node_modules. Node built-ins only, so it runs via node with no install, and it doesn't reimplement the per-file table nyc already prints. Tests are black-box, run with node's own test runner: a temp tree plus a json-summary report, the script invoked via node, output asserted. They cover missing-file detection, all-tracked, test-file and node_modules exclusion, and the missing-report error. make test gained a node --test discovery path for languages/*/tests, guarded so environments without Node skip it cleanly. As with Python, the TypeScript bundle had no gitignore-add.txt, which would have left the script un-gitignored on install, so I added one. This finishes the fan-out: coverage-summary now ships in all four bundles, each parsing its own tool's report behind the same file-weighted, missing-as-0% kernel. I proved the Go and TypeScript scripts by running them (Go against a live profile, TS against a synthetic report and the CLI). Python and TypeScript weren't run against a live coverage tool, since neither coverage.py nor nyc is installed here, so the first adopter of each should check against a real report.
Diffstat (limited to 'languages/typescript/claude/rules')
-rw-r--r--languages/typescript/claude/rules/typescript-testing.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/languages/typescript/claude/rules/typescript-testing.md b/languages/typescript/claude/rules/typescript-testing.md
index bd6933f..31c50fc 100644
--- a/languages/typescript/claude/rules/typescript-testing.md
+++ b/languages/typescript/claude/rules/typescript-testing.md
@@ -113,6 +113,23 @@ Workflow: invoke `/pairwise-tests` → get a PICT model + generated test matrix
→ paste the matrix into an `it.each` block. See `testing.md` § Combinatorial
Coverage for the general rule and when to skip.
+## Measuring Coverage — `make coverage-summary`
+
+The bundle ships a coverage summary at `.claude/scripts/coverage-summary.js`
+and a Makefile fragment (`coverage-makefile.txt`) with `coverage` and
+`coverage-summary` targets. After the suite runs under c8 (or Vitest/Jest with
+the json-summary reporter) and writes `coverage/coverage-summary.json`, `make
+coverage-summary` prints a file-weighted project number and the source files no
+test imported.
+
+The number to watch is that missing-file count. A module no test imports never
+appears in the Istanbul report, so a statement-weighted total skips it silently
+and the suite looks healthier than it is. The summary counts every `.ts`/`.js`
+under the source dir that's absent from the report as 0%, so an untested module
+drags the project number down where you can see it. It doesn't reimplement the
+per-file table — nyc/c8 already print that. Copy the fragment's targets into
+your own Makefile to adopt it; the bundle never edits your Makefile.
+
## Mocking Guidelines
### Mock these (external boundaries):