On this page
CLI test-coverage instrumentation: per-process shard files recording which commands app.test() exercised, plus the built-in cli-test-coverage provider.
#typescript/src/checks/coverage
#typescript/src/checks/coverage
CLI test-coverage instrumentation: per-process shard files recording which commands app.test() exercised, plus the built-in cli-test-coverage provider. The provider merges the committed manifest and shard files into the covered set and compares it against the app's full command surface.
Parity sources: go/strictcli/coverage.go with Python _record_coverage / _collect_all_command_paths / _test_coverage_provider as the divergence ground truth.
#initTestCoverage
export function initTestCoverage(app: AppImpl): voidEnables test-coverage instrumentation on an app. Anchors the coverage root to the cwd AT CONSTRUCTION TIME (both the recorder and the check provider use these absolute paths, so tests which chdir still record into the repo and a check evaluated from a foreign cwd reads the app's own repo state), creates the shard directory eagerly (a failure here is a hard construction error), and registers the built-in cli-test-coverage provider.
#recordCoverage
export function recordCoverage(app: AppImpl, cmdPath: string): voidAppends a coverage record for the resolved command path. Each test() or call() invocation appends one JSONL line to the per-process shard file.
#collectAllCommandPaths
export function collectAllCommandPaths(app: AppImpl): Set<string>Enumerates all non-deprecated leaf command paths as dot-separated strings (e.g. "deploy", "infra.deploy").
#testCoverageProvider
export function testCoverageProvider(app: AppImpl): () => CheckSpec[]The built-in check provider for cli-test-coverage, auto-registered when the app enables testCoverage. The verdict is derived from committed state: the covered set is the union of the committed manifest (.strictcli/test-coverage.json) and any per-process shard files merged from .strictcli/coverage/. Every live registered command path (minus the injected check command) must be present in that union to pass; otherwise the check fails naming each uncovered command.
Because the verdict reads the committed manifest, it is deterministic on every machine -- a machine that never ran the suite (no local shards) still gets a stable verdict from the committed manifest alone.
The manifest is rewritten as the monotonic union of its prior contents and the freshly merged shards, but ONLY when that content actually changes -- a pure check must not dirty a byte-identical file. Accepted staleness: deleting a test leaves its command covered in the manifest until the manifest is deliberately regenerated, because the union never removes a command.