Everything you need to run, test, extend, and contribute to this extension.
- Node.js 20+
- VS Code 1.90+
- npm (comes with Node)
git clone https://github.com/kool7/coverage-visualizer.git
cd coverage-visualizer
npm install
npm run compilePress F5 in VS Code to open the Extension Development Host with the extension loaded.
The extension is split into two intentional layers:
src/parsers/coverageParser.ts — pure logic, no VS Code dependency
All data transformation: parsing coverage.json / coverage.xml / .coverage SQLite, normalising into a unified CoverageReport, matching file paths, collapsing line numbers into ranges. Independently testable with Jest.
src/extension.ts — VS Code integration only
Activation, command registration, decoration lifecycle, onDidChangeActiveTextEditor listener, and file watchers. Holds the current CoverageReport in module-level state so decorations reapply without re-reading from disk.
Data flow:
pytest --cov=. --cov-report=json
→ coverage.json (or .xml or .coverage)
→ parser (coverageParser.ts)
→ CoverageReport (unified in-memory model)
→ applyToEditor() per open editor
→ CodeLens / Hover / TreeView / StatusBar / Dashboard
File watcher: activated at startup on coverage.json, coverage.xml, and .coverage. Create, change, or delete triggers an automatic re-parse and redecorate.
src/
extension.ts # Entry point — commands, decorations, watchers
config.ts # Typed wrapper for all extension settings
parsers/
coverageParser.ts # JSON, XML, SQLite parsers + shared utilities
providers/
codeLensProvider.ts # Coverage % above def/class
hoverProvider.ts # Hover tooltip on highlighted lines
treeProvider.ts # Explorer sidebar tree view
ui/
dashboardPanel.ts # WebView dashboard (ring chart, file table)
statusBar.ts # Status bar item
tests/
coverageParser.test.ts # Jest tests for all three parser formats
fixtures/
coverage.json # Realistic JSON fixture (3 files: partial/100%/0%)
coverage.xml # Cobertura XML fixture
.coverage # SQLite fixture (generated by scripts/)
src/ # Python source files for SQLite missing-line inference
__mocks__/vscode.ts # VS Code API mock for Jest
scripts/
generate-test-coverage-db.mjs # Regenerates tests/fixtures/.coverage
assets/
demo.gif # Marketplace demo GIF
npm run compile # TypeScript → out/
npm run watch # Recompile on save (dev mode)
npm test # Run all Jest tests
npm run test:watch # Jest in watch mode
npm run test:coverage # Jest with coverage report (→ coverage/)
npm run lint # ESLint on src/Run a single test file:
npx jest tests/coverageParser.test.tsRun a single test by name:
npx jest -t "groups consecutive lines"The .coverage SQLite fixture is synthetic — generated from a script so no Python installation is required:
node scripts/generate-test-coverage-db.mjs
cp demo-python-project/.coverage tests/fixtures/.coverageRun this whenever you change which lines are executed in scripts/generate-test-coverage-db.mjs. The Python source files in tests/fixtures/src/ must match whatever the fixture expects for missing-line inference to work.
- Add
parseXxx(input): CoverageReportinsrc/parsers/coverageParser.ts - Add format detection in
detectAndParse()insrc/extension.ts - Add a file watcher pattern in
setupWatchers()insrc/extension.ts - Add a fixture file in
tests/fixtures/and tests intests/coverageParser.test.ts
- File matching —
findFileInReportuses a suffix/contains check against coverage file keys. Coverage.py stores relative paths (e.g.src/calc.py); VS Code provides absolute paths. This breaks if the workspace root doesn't contain the relative path as a suffix — a known gap. module: "Node16"in tsconfig requires explicit.jsextensions on relative imports in source files, even though they're.ts. Do not change to CommonJS.better-sqlite3is listed as a dependency but is unused — remove it when adding the next feature.
- One feature or fix per PR — keep it focused
- All existing tests must pass:
npm test - TypeScript must compile cleanly:
npm run compile - Add tests for any new parser logic or bug fixes
- Write a clear PR description with what changed and why
- Branch naming:
feat/,fix/,chore/— no direct commits tomain