test-runners/coverage-badge
Renders a coverage badge from the coverage/lcov.info report testCoverage writes, as a self-contained SVG in the shields.io flat style, so a README can show the measured coverage with no external service. The obsidian-plugin-ci.yml reusable workflow publishes it to a badges branch; see the CI and release guide.
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| CoverageCount | A covered and a total count of one kind of coverage item. |
| CoverageTotals | The coverage totals of a whole lcov report. |
| GenerateCoverageBadgeOptions | Options for generateCoverageBadge. |
| GenerateCoverageBadgeResult | The result of generateCoverageBadge. |
| RenderCoverageBadgeSvgParams | Parameters for renderCoverageBadgeSvg. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| generateCoverageBadge | Reads the lcov report, renders the badge and writes it. |
| getCoverageBadgeColor | Picks the badge color of a coverage figure, on the shields.io scale. |
| getCoveragePercent | Computes the figure a badge shows. A kind with nothing to cover counts as fully covered, as vitest’s own summary reports it. The figure is rounded DOWN to one decimal, so a project at 99.96% never shows 100%. |
| parseLcovTotals | Sums the per-file counts of an lcov report. |
| renderCoverageBadgeSvg | Renders a coverage badge in the shields.io flat style. |
| Type | Description |
|---|---|
| CoverageBadgeMetric | Which coverage figure the badge shows. - lines: the share of lines covered, the figure most coverage services show. - functions: the share of functions covered. - branches: the share of branches covered. - lowest: the lowest of the three, so the badge never shows a figure one of the others falls below. |