Add Playwright fixture for CSS coverage collection#135
Open
bartveneman wants to merge 4 commits into
Open
Conversation
Exposes a `test` fixture via `@projectwallace/css-code-coverage/playwright` that starts/stops CSS coverage around each test and writes JSON files to disk automatically. The output directory defaults to `css-coverage` and is configurable via the `cssCoverageDir` fixture option in playwright.config.ts. Closes #134
Users should explicitly request cssCoverage in each test rather than having it run automatically for all tests. The expect re-export was unnecessary since users import it directly from @playwright/test.
Bundle ReportChanges will increase total bundle size by 1.44kB (5.28%) ⬆️
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #135 +/- ##
=======================================
Coverage 96.76% 96.76%
=======================================
Files 14 14
Lines 1081 1081
Branches 143 143
=======================================
Hits 1046 1046
Misses 34 34
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
This PR adds a new Playwright fixture that enables automatic CSS coverage collection and reporting for individual tests. The fixture integrates with Playwright's built-in coverage API and outputs results as JSON files that can be analyzed with the existing CLI tools.
Key Changes
New Playwright fixture module (
src/playwright/index.ts): Exports a customtestfixture that extends Playwright's base test with CSS coverage collection capabilitiescssCoveragefixture: Automatically starts/stops CSS coverage for each test and writes results to diskcssCoverageDiroption: Configurable output directory (defaults tocss-coverage)Build configuration: Added tsdown entry point for the new Playwright module with proper ESM output and external dependency handling
Package exports: Updated
package.jsonto expose the new fixture via@projectwallace/css-code-coverage/playwrightsubpath exportDocumentation: Added comprehensive usage guide in README covering:
Implementation Details
cssCoverageDiris a worker-scoped option, allowing configuration at the test suite levelhttps://claude.ai/code/session_018rtpbM5EyF5KJTUBiA7JSc