feat: add auto-fixture for Istanbul E2E coverage collection#95
Open
gustavolira wants to merge 1 commit intoredhat-developer:mainfrom
Open
feat: add auto-fixture for Istanbul E2E coverage collection#95gustavolira wants to merge 1 commit intoredhat-developer:mainfrom
gustavolira wants to merge 1 commit intoredhat-developer:mainfrom
Conversation
Add a `_coverageCollector` auto-fixture that collects `window.__coverage__` from the browser after each test and writes it to a JSON file. This enables E2E coverage collection for instrumented dynamic plugins without modifying any test files. Guarded by E2E_COLLECT_COVERAGE=1 — zero overhead when disabled. Coverage files are written to coverage/istanbul/ (or COVERAGE_OUTPUT_DIR) and consumed by the overlay repo's coverage reporter for merging into lcov and uploading to Codecov. Part of the E2E coverage pipeline: RHIDP-13411 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_coverageCollectorauto-fixture to the sharedtestobject that automatically collectswindow.__coverage__from the browser after each testE2E_COLLECT_COVERAGE=1— zero overhead when disabled (nopage.evaluate, no fs operations)coverage/istanbul/(configurable viaCOVERAGE_OUTPUT_DIR)Why
The rhdh-plugin-export-overlays repo builds Istanbul-instrumented dynamic plugins and runs E2E tests against them. The instrumented plugins populate
window.__coverage__in the browser, but nothing collects it today.Since all 18 workspace test files import
testfrom@red-hat-developer-hub/e2e-test-utils/test, adding an auto-fixture here gives every test automatic coverage collection without modifying any test file.How it works
Design decisions
auto: true— runs for every test without test file changesscope: "test"— collects per-test, not per-workerawait use()first — teardown runs AFTER the test but BEFOREpagecloses (Playwright tears down in reverse dependency order)try/catchwith empty catch — best-effort; if the page crashed or plugin wasn't instrumented, silently skip_prefix — Playwright convention for internal auto-fixturesnode:fsand existingpathimportRelated PRs
Test plan
yarn buildsucceedsyarn typecheckpassesE2E_COLLECT_COVERAGE=1and an instrumented plugin: JSON files appear incoverage/istanbul/E2E_COLLECT_COVERAGE: no JSON files, no performance impact🤖 Generated with Claude Code