Code Coverage Report
A test coverage dashboard with an overall-percentage summary bar and a two-level expandable file tree below it: folders open to reveal files, and each file shows its statements, branches, functions, and lines coverage as small color-coded percentage chips. Built for CI dashboards, docs pages, and internal quality reports.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/code-coverage-report.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/devtools/devtools22.tsx instead.
Usage
The file also exports devtools22Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Devtools22, devtools22Demo } from "@/components/blocks/devtools/devtools22"; export default function Page() { return <Devtools22 {...devtools22Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Code Coverage Report" | Section heading. |
| description | string | undefined | Section intro text below the heading. |
| overall | OverallCoverage | none | Aggregate percentages shown in the summary row above the tree. |
| folders | FolderCoverage[] | [] | Top-level folders in the tree, each expandable to reveal its files. |
| defaultOpenFolders | string[] | [] | Folder names (matched against FolderCoverage.name) that render expanded on first render. |
| className | string | none | Extra classes for the outer section element. |
Types
type FileCoverage = { name: string; statements: number; branches: number; functions: number; lines: number; }; type FolderCoverage = { name: string; files: FileCoverage[] }; type OverallCoverage = { statements: number; branches: number; functions: number; lines: number; };
Behavior notes
- "use client" only for the folder expand/collapse state; expanding a folder is real local state, nothing else in the block is interactive.
- defaultOpenFolders sets which folders start expanded via a lazy useState initializer read once on mount, not an effect, so it never fights with the user toggling folders afterward.
- The tree is exactly two levels deep (folders, then files); there is no nested-subfolder recursion.
- Coverage chip color thresholds are fixed: 80% and above is emerald, 50 to 79% is amber, below 50% is red, applied identically to the overall summary and every per-file chip.
- The overall summary numbers are caller-supplied and are not computed by averaging the folders/files data, so they can be set independently of what the tree actually contains.
More DevTools Blocks
View all →api-endpoints-sample-call
API Endpoints With Sample Call
Reference list of API endpoints paired with a live sample request and response panel.
cicd-pipeline-status
CI/CD Pipeline Status
Recent CI/CD pipeline runs with per-stage status chips and overall run badges.
code-diff-viewer
Code Diff Viewer
Unified code diff panel with a file header change summary and colored addition/deletion lines.
keyboard-shortcuts-reference
Keyboard Shortcuts Reference
Grouped keyboard shortcut reference with keycap-styled key combos.
performance-waterfall
Performance Waterfall
Network request waterfall chart with cascading timing bars colored by duration.
service-health-board
Service Health Board
Infrastructure status board with a live summary strip and per-service uptime, latency, and health.