Skip to content

Commit 1f8c516

Browse files
gustavoliraclaude
andauthored
feat(e2e-coverage): scaffold Playwright page.coverage collection (#4680)
* feat(e2e-coverage): scaffold Playwright page.coverage collection (RHIDP-13243) Scaffolding for E2E frontend coverage on the rhdh repo (part of RHDHPLAN-851, Epic RHIDP-13242). Opt-in via COLLECT_COVERAGE=true; default behavior unchanged so existing E2E runs are unaffected. Infrastructure only - Extended test fixture at e2e-tests/playwright/support/coverage/test.ts that wraps page.coverage.startJSCoverage / stopJSCoverage around each test when COLLECT_COVERAGE=true. - Playwright reporter at e2e-tests/playwright/support/coverage/reporter.ts that aggregates raw V8 output into a merged Istanbul LCOV + HTML report via monocart-coverage-reports. - Reporter registered conditionally in playwright.config.ts so it is a no-op unless COLLECT_COVERAGE=true. - monocart-coverage-reports@2.12.11 added to e2e-tests devDependencies. - Docs at docs/coverage/e2e-rhdh.md covering usage, migration pattern, env vars, known limitations. - .gitignore tweaks so source code under paths containing "coverage" (docs/coverage, e2e-tests/playwright/support/coverage) is tracked while the generated "coverage/" output dirs remain ignored. No specs are migrated in this PR. Specs opt in via: import { test, expect } from "../support/coverage/test"; Follow-ups (separate PRs) - Migrate one spec (e.g. smoke-test) to validate the pipeline end-to-end. - Wire CI step to upload lcov.info to Codecov with flag rhdh-e2e-frontend. - Evaluate instrumented showcase image variant (RHIDP-13244 spike). Refs - https://issues.redhat.com/browse/RHIDP-13243 - https://issues.redhat.com/browse/RHIDP-13242 - https://issues.redhat.com/browse/RHDHPLAN-851 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(e2e-coverage): update yarn.lock for monocart-coverage-reports Previous commit added monocart-coverage-reports@2.12.11 to e2e-tests/package.json but did not update e2e-tests/yarn.lock. Yarn's hardened mode on public PRs forbids lockfile modifications during install, which blocks the CI lint/prettier/shellcheck step. Regenerated the lockfile locally with `yarn install`. Only new entries for monocart-coverage-reports and its transitive deps. Refs - #4680 - https://issues.redhat.com/browse/RHIDP-13243 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(e2e-coverage): satisfy ESLint naming and no-unused-vars rules CI lint step rejected the new files under e2e-tests/playwright/support/coverage/ because of the project eslint-config naming rules. Fixes: - Rename top-level `const` variables to camelCase (COVERAGE_RAW_DIR/COVERAGE_REPORT_DIR/COVERAGE_OUTPUT_DIR → camelCase) - Drop unused `_config` and `_result` parameters on Reporter.onBegin / onEnd (the Reporter interface allows narrower implementations). - Replace destructuring `const { CoverageReport } = await import(...)` with `const monocart = await import(...)` + `new monocart.CoverageReport(...)` so the PascalCase class name does not trip the variable naming rule. - Keep the Playwright-idiomatic `export const test` and `export const expect` names, guarded by `eslint-disable-next-line @typescript-eslint/naming-convention` with a comment explaining the rationale (renaming would force every consumer to alias on import, degrading the DX). Verified locally: - `npx eslint playwright/support/coverage/test.ts playwright/support/coverage/reporter.ts` clean - `yarn prettier:check playwright/support/coverage/` clean - `yarn tsc:check` clean Refs - #4680 - https://issues.redhat.com/browse/RHIDP-13243 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(e2e-coverage): address review feedback on scaffolding Harden the Playwright coverage scaffolding based on review notes so the first COLLECT_COVERAGE=true runs do not surface papercuts in CI. Correctness - Filename collision under parallel workers: raw V8 coverage files now include workerIndex and retry in the filename, and the title is taken from testInfo.titlePath (describe chain included) rather than just title. Two specs with identical titles in different describe blocks no longer collide. - Silent error swallow in reporter.readdir: the catch now only swallows ENOENT (directory missing on first run). Any other I/O error rethrows so CI logs show the real cause instead of the misleading "no coverage collected" warning. - JSON shape guard: entries loaded from raw files are verified to be arrays before handing to monocart. Corrupted or unexpected files are skipped with a clear warning instead of failing deep inside the library. Structure - Extracted the env-var-to-path resolution into a shared paths.ts, so the fixture and reporter can never drift on COVERAGE_OUTPUT_DIR / COVERAGE_REPORT_DIR. Exports follow the project UPPER_CASE convention for exported const. Hardening - Timeout wrapper (default 2 min, COVERAGE_GENERATE_TIMEOUT_MS override) around monocart.CoverageReport.generate(). A hung aggregation can no longer hold the Playwright run open in CI. - Parallel file reads via Promise.all. Scales better as the full 64-spec suite starts emitting coverage. Readability - playwright.config.ts uses `satisfies ReporterDescription[]` instead of the earlier `as [string]` cast — removes the type gymnastics while keeping the conditional registration. - Inline comments on startJSCoverage options explain the rationale for resetOnNavigation: false and reportAnonymousScripts: false. - Reworded the dynamic-import comment to match what it actually does (defers monocart load until generation time; the dep is installed regardless because it's in devDependencies). Docs - docs/coverage/e2e-rhdh.md updated with: - new env var COVERAGE_GENERATE_TIMEOUT_MS - note on the new filename scheme (workerIndex + retry) so the parallel collision question is explicit - import path examples for specs at depths 2, 3, and 4 (there is no tsconfig path alias configured) Local validation - npx eslint playwright/support/coverage/*.ts playwright.config.ts: clean - yarn tsc: clean - yarn prettier:check (coverage files + playwright.config.ts + docs): clean Refs - #4680 - https://issues.redhat.com/browse/RHIDP-13243 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(e2e-coverage): address qodo review findings (bugs 2, 5, 7) Addresses actionable findings from the Qodo automated review. Three of the seven flagged items are real bugs that are fixed here; the other four are either false positives or scope decisions covered in the PR reply. Fixed - Stale raw files across runs (qodo #2). The reporter's onBegin now does `fs.rm COVERAGE_RAW_DIR` followed by `mkdir`, so the merged report only reflects the current Playwright run. Without this the raw dir accumulated *.json across runs and produced an incorrect LCOV. - Coverage teardown could fail tests (qodo #5). Both startJSCoverage and the file-write teardown are now wrapped in try/catch with a console.warn. Coverage collection is best-effort and can never fail a test run, including scenarios like unsupported browsers, pages closed before teardown, or transient I/O errors. - Custom-context specs silently skipped (qodo #7). Exported two helpers — startCoverageForPage(page) and stopCoverageForPage(page, testInfo) — so specs that manage their own BrowserContext/Page via browser.newContext() (e.g. plugins/adoption-insights, plugins/ scorecard) can opt in explicitly. Helpers are no-ops when COLLECT_COVERAGE is unset and share the same error-safe wrappers as the auto fixture. Not changed (with reason) - Fixture typing (qodo #1) — false positive. Reproduced locally: a migrated spec destructuring `{ page }` from the extended test compiles clean under `yarn tsc`. Kept `<NonNullable<unknown>>`. - Global fixture for every spec (qodo #3) — intentional scope. A per-spec import migration is phased so each batch lands in its own reviewable PR. Playwright does not offer a mechanism to override the test import globally without editing every spec file. - Codecov upload step (qodo #4) — intentional scope, depends on RHIDP-13230 (Codecov GitHub App + Vault token) landing first. The upload step is tracked for the follow-up CI wiring PR. - Source-map validation (qodo #6) — validation requires a running RHDH instance against which to run the instrumented suite. Planned as part of the first real COLLECT_COVERAGE=true run rather than a scaffolding PR. Docs updated - docs/coverage/e2e-rhdh.md now documents the custom-context pattern with a full example using startCoverageForPage / stopCoverageForPage, plus a "Specs that have not migrated" note making the phased migration explicit. Local validation - npx eslint playwright/support/coverage/*.ts: clean - yarn tsc: clean - yarn prettier:check (coverage + docs): clean Refs - #4680 - https://issues.redhat.com/browse/RHIDP-13243 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(e2e-coverage): address PR review feedback on gitignore patterns Replace broad **/coverage ignore with scoped rules per zdrapela's review: - Root .gitignore: target dynamic-plugins/packages/plugins coverage dirs - e2e-tests/.gitignore: use /coverage/ instead of exclusion patterns - Add coverage to e2e-tests/.prettierignore and eslint ignores Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs(e2e-coverage): add AI assistant rule for instrumented imports Adds a rulesync rule that instructs AI assistants (Cursor, Claude Code, OpenCode) to use the coverage-instrumented test/expect imports instead of @playwright/test when creating or modifying spec files. Suggested-by: zdrapela Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor(e2e-coverage): add @support path alias for coverage imports Add a TypeScript path alias @support/* → playwright/support/* in e2e-tests/tsconfig.json so specs can use a clean, depth-independent import instead of fragile relative paths. Update docs, code comments, and AI assistant rules accordingly. Suggested-by: zdrapela Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 056d644 commit 1f8c516

16 files changed

Lines changed: 794 additions & 6 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
paths:
3+
- e2e-tests/playwright/**/*.spec.ts
4+
- e2e-tests/playwright/**/*.test.ts
5+
---
6+
# E2E Coverage: Use Instrumented Imports
7+
8+
When creating or modifying Playwright spec files under `e2e-tests/playwright/`, always use the coverage-instrumented `test` and `expect` instead of importing directly from `@playwright/test`.
9+
10+
## Import Rule
11+
12+
```typescript
13+
// WRONG - bypasses coverage collection
14+
import { test, expect } from "@playwright/test";
15+
16+
// CORRECT - uses the @support path alias (configured in e2e-tests/tsconfig.json)
17+
import { test, expect } from "@support/coverage/test";
18+
```
19+
20+
The instrumented version is a drop-in replacement: `describe`, `beforeAll`, `expect`, locators, and all fixtures behave identically. When `COLLECT_COVERAGE` is unset (the default), the instrumented fixture is a no-op with zero overhead.
21+
22+
## Specs with Custom Context
23+
24+
If the spec creates its own `BrowserContext` / `Page` via `browser.newContext()`, also import and call the explicit helpers:
25+
26+
```typescript
27+
import { test, expect, startCoverageForPage, stopCoverageForPage } from "@support/coverage/test";
28+
29+
test("my test", async ({}, testInfo) => {
30+
const context = await browser.newContext();
31+
const page = await context.newPage();
32+
await startCoverageForPage(page);
33+
try {
34+
// test body
35+
} finally {
36+
await stopCoverageForPage(page, testInfo);
37+
}
38+
});
39+
```
40+
41+
## Reference
42+
43+
See `docs/coverage/e2e-rhdh.md` for full details on the coverage infrastructure.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
globs: e2e-tests/playwright/**/*.spec.ts,e2e-tests/playwright/**/*.test.ts
3+
---
4+
5+
# E2E Coverage: Use Instrumented Imports
6+
7+
When creating or modifying Playwright spec files under `e2e-tests/playwright/`, always use the coverage-instrumented `test` and `expect` instead of importing directly from `@playwright/test`.
8+
9+
## Import Rule
10+
11+
```typescript
12+
// WRONG - bypasses coverage collection
13+
import { test, expect } from "@playwright/test";
14+
15+
// CORRECT - uses the @support path alias (configured in e2e-tests/tsconfig.json)
16+
import { test, expect } from "@support/coverage/test";
17+
```
18+
19+
The instrumented version is a drop-in replacement: `describe`, `beforeAll`, `expect`, locators, and all fixtures behave identically. When `COLLECT_COVERAGE` is unset (the default), the instrumented fixture is a no-op with zero overhead.
20+
21+
## Specs with Custom Context
22+
23+
If the spec creates its own `BrowserContext` / `Page` via `browser.newContext()`, also import and call the explicit helpers:
24+
25+
```typescript
26+
import { test, expect, startCoverageForPage, stopCoverageForPage } from "@support/coverage/test";
27+
28+
test("my test", async ({}, testInfo) => {
29+
const context = await browser.newContext();
30+
const page = await context.newPage();
31+
await startCoverageForPage(page);
32+
try {
33+
// test body
34+
} finally {
35+
await stopCoverageForPage(page, testInfo);
36+
}
37+
});
38+
```
39+
40+
## Reference
41+
42+
See `docs/coverage/e2e-rhdh.md` for full details on the coverage infrastructure.

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ yarn-debug.log*
99
yarn-error.log*
1010
lerna-debug.log*
1111

12-
# Coverage directory generated when running tests with coverage
13-
**/coverage
12+
# Coverage directories generated by test runs
13+
dynamic-plugins/**/coverage/
14+
packages/*/coverage/
15+
plugins/*/coverage/
16+
# Python coverage data (pytest --cov)
1417
**/.coverage
1518
# Dependencies
1619
node_modules/
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# E2E Coverage: Use Instrumented Imports
2+
3+
When creating or modifying Playwright spec files under `e2e-tests/playwright/`, always use the coverage-instrumented `test` and `expect` instead of importing directly from `@playwright/test`.
4+
5+
## Import Rule
6+
7+
```typescript
8+
// WRONG - bypasses coverage collection
9+
import { test, expect } from "@playwright/test";
10+
11+
// CORRECT - uses the @support path alias (configured in e2e-tests/tsconfig.json)
12+
import { test, expect } from "@support/coverage/test";
13+
```
14+
15+
The instrumented version is a drop-in replacement: `describe`, `beforeAll`, `expect`, locators, and all fixtures behave identically. When `COLLECT_COVERAGE` is unset (the default), the instrumented fixture is a no-op with zero overhead.
16+
17+
## Specs with Custom Context
18+
19+
If the spec creates its own `BrowserContext` / `Page` via `browser.newContext()`, also import and call the explicit helpers:
20+
21+
```typescript
22+
import { test, expect, startCoverageForPage, stopCoverageForPage } from "@support/coverage/test";
23+
24+
test("my test", async ({}, testInfo) => {
25+
const context = await browser.newContext();
26+
const page = await context.newPage();
27+
await startCoverageForPage(page);
28+
try {
29+
// test body
30+
} finally {
31+
await stopCoverageForPage(page, testInfo);
32+
}
33+
});
34+
```
35+
36+
## Reference
37+
38+
See `docs/coverage/e2e-rhdh.md` for full details on the coverage infrastructure.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
root: false
3+
targets:
4+
- '*'
5+
globs:
6+
- e2e-tests/playwright/**/*.spec.ts
7+
- e2e-tests/playwright/**/*.test.ts
8+
---
9+
# E2E Coverage: Use Instrumented Imports
10+
11+
When creating or modifying Playwright spec files under `e2e-tests/playwright/`, always use the coverage-instrumented `test` and `expect` instead of importing directly from `@playwright/test`.
12+
13+
## Import Rule
14+
15+
```typescript
16+
// WRONG - bypasses coverage collection
17+
import { test, expect } from "@playwright/test";
18+
19+
// CORRECT - uses the @support path alias (configured in e2e-tests/tsconfig.json)
20+
import { test, expect } from "@support/coverage/test";
21+
```
22+
23+
The instrumented version is a drop-in replacement: `describe`, `beforeAll`, `expect`, locators, and all fixtures behave identically. When `COLLECT_COVERAGE` is unset (the default), the instrumented fixture is a no-op with zero overhead.
24+
25+
## Specs with Custom Context
26+
27+
If the spec creates its own `BrowserContext` / `Page` via `browser.newContext()`, also import and call the explicit helpers:
28+
29+
```typescript
30+
import { test, expect, startCoverageForPage, stopCoverageForPage } from "@support/coverage/test";
31+
32+
test("my test", async ({}, testInfo) => {
33+
const context = await browser.newContext();
34+
const page = await context.newPage();
35+
await startCoverageForPage(page);
36+
try {
37+
// test body
38+
} finally {
39+
await stopCoverageForPage(page, testInfo);
40+
}
41+
});
42+
```
43+
44+
## Reference
45+
46+
See `docs/coverage/e2e-rhdh.md` for full details on the coverage infrastructure.

docs/coverage/e2e-rhdh.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# E2E Code Coverage for the RHDH Repository
2+
3+
Jira: [RHIDP-13243](https://issues.redhat.com/browse/RHIDP-13243)
4+
Epic: [RHIDP-13242](https://issues.redhat.com/browse/RHIDP-13242)
5+
Feature: [RHDHPLAN-851](https://issues.redhat.com/browse/RHDHPLAN-851)
6+
7+
## What this is
8+
9+
This document describes how the `e2e-tests/` Playwright suite collects JavaScript
10+
coverage from Chromium while exercising a deployed RHDH instance, and how that
11+
coverage flows to Codecov.
12+
13+
Scope of this mechanism:
14+
15+
- **What it measures**: frontend JS/TS in `packages/app/src/**` and related modules,
16+
exercised by the Playwright specs in `e2e-tests/playwright/e2e/`.
17+
- **What it does not measure**: backend-only code, code not loaded by the browser
18+
during the E2E run, plugins delivered as separate OCI images (tracked under
19+
RHIDP-11866 via CoverPort).
20+
21+
## How it works
22+
23+
1. **Opt-in via env var.** When `COLLECT_COVERAGE=true`, a Playwright fixture
24+
(`e2e-tests/playwright/support/coverage/test.ts`) extends the base `test`
25+
and wraps each run with `page.coverage.startJSCoverage()` / `stopJSCoverage()`.
26+
Raw V8 coverage is persisted per test as JSON under `coverage/e2e-raw/`.
27+
2. **Aggregation at run end.** A Playwright reporter
28+
(`e2e-tests/playwright/support/coverage/reporter.ts`) reads the raw files at
29+
`onEnd` and uses `monocart-coverage-reports` to convert V8 output to
30+
Istanbul format and emit a merged LCOV + HTML report under `coverage/e2e/`.
31+
3. **Codecov upload (CI, follow-up).** A CI step uploads `coverage/e2e/lcov.info`
32+
to Codecov with the flag `rhdh-e2e-frontend`. This step lands in a follow-up
33+
PR (see Known Limitations below).
34+
35+
With `COLLECT_COVERAGE` unset (the default), the fixture and reporter are no-ops
36+
and the E2E suite runs identically to the pre-coverage configuration.
37+
38+
## How to use it locally
39+
40+
### Prerequisites
41+
42+
- A deployed RHDH reachable via `BASE_URL`
43+
- `yarn install` completed in `e2e-tests/`
44+
- Node.js 24
45+
46+
### Run a spec with coverage enabled
47+
48+
```bash
49+
cd e2e-tests
50+
COLLECT_COVERAGE=true yarn playwright test playwright/e2e/smoke-test.spec.ts
51+
```
52+
53+
Outputs:
54+
55+
- `e2e-tests/coverage/e2e-raw/` — one JSON file per test run (raw V8 coverage)
56+
- `e2e-tests/coverage/e2e/` — merged report: `lcov.info`, `coverage-summary.json`,
57+
HTML dashboard at `index.html`
58+
59+
### View the HTML report
60+
61+
```bash
62+
open e2e-tests/coverage/e2e/index.html
63+
```
64+
65+
## Migrating a spec to capture coverage
66+
67+
There are two patterns depending on how the spec manages its browser page.
68+
69+
### Specs that use the built-in `{ page }` fixture (most specs)
70+
71+
Opt in by importing the extended `test`/`expect` from the coverage helper
72+
instead of `@playwright/test`:
73+
74+
```ts
75+
// Before
76+
import { test, expect } from "@playwright/test";
77+
78+
// After — uses the @support path alias (configured in tsconfig.json),
79+
// so the import is the same regardless of file depth:
80+
import { test, expect } from "@support/coverage/test";
81+
```
82+
83+
The rest of the spec stays identical — `describe`, `beforeAll`, `expect`,
84+
locators, and fixtures behave exactly the same.
85+
86+
### Specs that create their own context/page via `browser.newContext()`
87+
88+
Several existing specs (for example `plugins/adoption-insights`,
89+
`plugins/scorecard`) manage their own `BrowserContext` and `Page` in
90+
`beforeAll` instead of using the default `{ page }` fixture. These specs
91+
bypass the auto-instrumented fixture above — they need to call the helpers
92+
explicitly:
93+
94+
```ts
95+
import { test, expect, startCoverageForPage, stopCoverageForPage } from "@support/coverage/test";
96+
97+
test.describe("my feature", () => {
98+
let context: BrowserContext;
99+
let page: Page;
100+
101+
test.beforeAll(async ({ browser }) => {
102+
context = await browser.newContext();
103+
page = await context.newPage();
104+
});
105+
106+
test("something", async ({}, testInfo) => {
107+
await startCoverageForPage(page);
108+
try {
109+
// test body ...
110+
} finally {
111+
await stopCoverageForPage(page, testInfo);
112+
}
113+
});
114+
});
115+
```
116+
117+
`startCoverageForPage` and `stopCoverageForPage` are safe to call
118+
unconditionally — they are no-ops when `COLLECT_COVERAGE` is unset, and any
119+
internal failure is logged rather than propagated so coverage collection
120+
cannot fail a test.
121+
122+
### Specs that have not migrated
123+
124+
Run normally and simply do not contribute to coverage data. Migration is
125+
phased by design — this PR lands the scaffolding; spec migration happens
126+
incrementally in follow-up PRs so each batch can be reviewed in isolation.
127+
128+
## Environment variables
129+
130+
| Variable | Default | Purpose |
131+
|---|---|---|
132+
| `COLLECT_COVERAGE` | (unset) | Set to `true` to enable coverage collection |
133+
| `COVERAGE_OUTPUT_DIR` | `<cwd>/coverage/e2e-raw` | Where per-test raw V8 coverage is written |
134+
| `COVERAGE_REPORT_DIR` | `<cwd>/coverage/e2e` | Where the merged Istanbul report is written |
135+
| `COVERAGE_GENERATE_TIMEOUT_MS` | `120000` (2 min) | Maximum time the reporter will wait for `monocart.CoverageReport.generate()` before aborting. Prevents a CI job from hanging if coverage aggregation stalls |
136+
137+
Raw coverage file names include the spec title path, worker index, and retry
138+
number (for example `Smoke_test_basic_flow-w0-r0-1714003200000.json`) so
139+
parallel workers and retries never overwrite each other's output.
140+
141+
## Known limitations
142+
143+
- **Chromium only.** `page.coverage` is a CDP feature and is not available in
144+
Firefox or WebKit. Chromium is the default browser for this suite, so this
145+
is not a practical issue today.
146+
- **Source maps required for navigable reports.** The deployed RHDH must ship
147+
source maps (or an equivalent mapping) for the report to link back to original
148+
source. If source maps are missing, coverage still works but will point to
149+
minified bundles. Validating source-map availability in the deployed image is
150+
a task in RHIDP-13243.
151+
- **CI upload not wired yet.** This PR lands the collection + aggregation
152+
infrastructure. The Codecov upload step in the Playwright CI jobs (handle_ocp_pull,
153+
handle_ocp_nightly) is a follow-up task.
154+
- **Specs not yet migrated.** This PR does not modify any existing spec. A
155+
follow-up PR migrates specs to the extended `test` import so they start
156+
contributing coverage data.
157+
158+
## Related coverage flags in Codecov
159+
160+
| Flag | Source | Scope |
161+
|---|---|---|
162+
| `rhdh` | Jest (`packages/*`, `plugins/*`) | Unit / integration |
163+
| `install-dynamic-plugins` | Vitest (`scripts/install-dynamic-plugins`) | Install script unit tests |
164+
| `rhdh-e2e-frontend` (new) | Playwright `page.coverage` | E2E frontend — this doc |
165+
| `rhdh-e2e-full` (future) | Instrumented showcase image variant | E2E frontend, higher fidelity (RHIDP-13244) |
166+
| `overlays-e2e-<plugin>` (future) | CoverPort Tekton | Upstream plugins via OCI (RHIDP-11866) |
167+
168+
## References
169+
170+
- Playwright coverage API: https://playwright.dev/docs/api/class-coverage
171+
- monocart-coverage-reports: https://github.com/cenfun/monocart-coverage-reports
172+
- Chrome DevTools Protocol — Coverage domain
173+
- RHDH Test Strategy Proposal (Google Doc): https://docs.google.com/document/d/1B-Jl1uwX3sdWOGqs9CN9rTFYH743q-o5YVMoAz_yPh8/edit

e2e-tests/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ yarn-debug.log*
99
yarn-error.log*
1010
lerna-debug.log*
1111

12-
# Coverage directory generated when running tests with coverage
13-
coverage
12+
# Coverage directory generated by Playwright (COLLECT_COVERAGE=true)
13+
/coverage/
1414

1515
# Dependencies
1616
node_modules/

e2e-tests/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.local-test
2+
coverage

e2e-tests/eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export default [
9191
"node_modules/**",
9292
"playwright-report/**",
9393
"test-results/**",
94+
"coverage/**",
9495
".local-test/**",
9596
".prettierrc.cjs",
9697
],

e2e-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"eslint-plugin-filenames": "1.3.2",
4747
"eslint-plugin-playwright": "2.7.1",
4848
"ioredis": "5.10.1",
49+
"monocart-coverage-reports": "2.12.11",
4950
"otplib": "12.0.1",
5051
"prettier": "3.8.1",
5152
"prettier-plugin-sh": "0.18.1",

0 commit comments

Comments
 (0)