@ng-prism/plugin-coverage 21.4.0 → 21.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +69 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # @ng-prism/plugin-coverage
2
+
3
+ Test coverage plugin for [@ng-prism/core](https://github.com/dyingangel666/ng-prism). Reads Istanbul/v8 coverage reports at build time and displays per-component test coverage metrics with a score circle in the tab bar.
4
+
5
+ > **Full documentation:** [ng-prism Docs — Coverage Plugin](https://dyingangel666.github.io/ng-prism/#/plugins/coverage)
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @ng-prism/plugin-coverage
11
+ ```
12
+
13
+ ### Peer Dependencies
14
+
15
+ | Package | Version |
16
+ |---|---|
17
+ | `@ng-prism/core` | `>=21.0.0` |
18
+ | `@angular/core` | `>=20.0.0` |
19
+
20
+ ## Setup
21
+
22
+ ```typescript
23
+ // ng-prism.config.ts
24
+ import { defineConfig } from '@ng-prism/core/config';
25
+ import { coveragePlugin } from '@ng-prism/plugin-coverage';
26
+
27
+ export default defineConfig({
28
+ plugins: [
29
+ coveragePlugin({
30
+ coveragePath: 'coverage/coverage-summary.json',
31
+ }),
32
+ ],
33
+ });
34
+ ```
35
+
36
+ ## What It Does
37
+
38
+ - Adds a **Coverage** panel to the addon tab bar
39
+ - Shows a **score circle** with the average coverage percentage (like the A11y panel)
40
+ - Displays 4 metric bars: Statements, Branches, Functions, Lines
41
+ - Color-coded thresholds: green (>= 80%), yellow (>= 50%), red (< 50%)
42
+ - Works with any test runner that outputs Istanbul-compatible coverage (Jest, Karma, Vitest, nyc, c8)
43
+
44
+ ## Options
45
+
46
+ | Option | Default | Description |
47
+ |---|---|---|
48
+ | `coveragePath` | `'coverage/coverage-summary.json'` | Path to the Istanbul coverage summary file (relative to workspace root) |
49
+
50
+ ## Example
51
+
52
+ Generate coverage with your test runner, then start the showcase:
53
+
54
+ ```bash
55
+ npx nx test my-lib --coverage
56
+ ng run my-lib:prism
57
+ ```
58
+
59
+ Each component's Coverage tab shows its statement, branch, function, and line coverage with a score circle in the tab bar.
60
+
61
+ ## How It Works
62
+
63
+ **Build time:** The `onComponentScanned` hook reads `coverage-summary.json` (cached per build run, with mtime-based invalidation) and matches entries to components by file path. Coverage data is injected into `showcaseConfig.meta.coverage`.
64
+
65
+ **Runtime:** The `CoveragePanelComponent` reads the metadata and renders the metric bars. The score circle is rendered in `PrismPanelHostComponent` using the same `A11yScoreComponent`. The panel component is lazy-loaded via `loadComponent`.
66
+
67
+ ## License
68
+
69
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-prism/plugin-coverage",
3
- "version": "21.4.0",
3
+ "version": "21.4.1",
4
4
  "description": "Test coverage panel for ng-prism.",
5
5
  "keywords": [
6
6
  "@ng-prism/core",