diff options
Diffstat (limited to 'languages/typescript/coverage-makefile.txt')
| -rw-r--r-- | languages/typescript/coverage-makefile.txt | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/languages/typescript/coverage-makefile.txt b/languages/typescript/coverage-makefile.txt new file mode 100644 index 0000000..64c7fcd --- /dev/null +++ b/languages/typescript/coverage-makefile.txt @@ -0,0 +1,45 @@ +# TypeScript / JavaScript coverage — Makefile fragment + setup recommendation +# +# This file is owned by the project, not the rulesets bundle. The bundle never +# edits your Makefile. Copy the two targets below into your own Makefile (and +# adjust the variables at the top), then delete this file or keep it as a note. +# +# What you get: +# make coverage runs the suite under c8 and writes an Istanbul +# json-summary report plus c8's own text table +# make coverage-summary prints a file-weighted project number and every +# source file on disk absent from the report, at 0%. +# +# Why the summary matters: a module no test imports never appears in the +# Istanbul report, so a statement-weighted total silently skips it. The summary +# weights by file and counts a missing file as 0%, so untested files stay +# visible. It does not reimplement the per-file table — nyc/c8 already print it. +# +# --------------------------------------------------------------------------- +# Prerequisite: an Istanbul json-summary report. +# +# c8: npx c8 --reporter=json-summary --reporter=text npm test +# vitest: vitest run --coverage --coverage.reporter=json-summary +# jest: jest --coverage --coverageReporters=json-summary +# +# All three write coverage/coverage-summary.json. The summary script needs +# nothing beyond Node's standard library — it parses the JSON. +# --------------------------------------------------------------------------- + +# Variables — adjust to your layout. +NODE ?= node +SOURCE_DIR ?= src +COVERAGE_FILE ?= coverage/coverage-summary.json +# The summary script ships with the bundle under .claude/scripts/ (gitignored). +COVERAGE_SUMMARY ?= .claude/scripts/coverage-summary.js + +coverage: + @npx c8 --reporter=json-summary --reporter=text npm test + @$(MAKE) coverage-summary + +coverage-summary: + @if [ ! -f $(COVERAGE_FILE) ]; then \ + echo "[!] No coverage file at $(COVERAGE_FILE). Run 'make coverage' first."; \ + exit 1; \ + fi + @$(NODE) $(COVERAGE_SUMMARY) $(COVERAGE_FILE) $(SOURCE_DIR) . |
