- Framework:
playwright - Use case:
features/coverage - Source repository: https://github.com/currents-dev/blog-playwright-coverage-demo
A tiny demo project that accompanies the Currents blog post “How To Measure Code Coverage in Playwright Tests” and demonstrates collecting JS + CSS coverage using Playwright’s page.coverage APIs (Chromium-only).
- Install deps:
npm install(repo uses@playwright/test,http-server,typescript). - Start a static server on port 5173:
npm run dev(runsnpx http-server -c-1 -p 5173 .). - Run tests (Chromium project):
npm test(playwright test --project=chromium). - The Playwright test writes raw coverage JSON files into
coverage/raw/(e.g.js.json,css.json, plus*-invalid.jsonvariants).
- Coverage test file
tests/coverage.spec.tscontains two flows:- “happy path” (fills qty/price, calculates total, loads items) + writes
coverage/raw/js.json+coverage/raw/css.json - “error path” (negative qty) + writes
js-invalid.json+css-invalid.json
- “happy path” (fills qty/price, calculates total, loads items) + writes
- Minimal demo app code
src/app.jswires DOM events, validation, calculation, and “load items” behavior.src/utils/math.jsincludes deliberately uncovered branches (qty === 0) + an unusedlegacyDiscount()to show uncovered code.src/services/api.jsfetches/api/items(tests stub this route).src/ui/validate.jsvalidates numbers + negative inputs.styles.cssincludes.hiddenand.errorto show CSS coverage.
- Sample raw coverage outputs checked into the repo
coverage/raw/js.jsonandcoverage/raw/css.jsonare present and show the raw V8 coverage format produced by Playwright.
- Config
playwright.config.tsruns only Chromium because coverage APIs work only there.
- Start from the copied source markdown files in this folder and identify the exact config files/scripts used.
- Create or reuse a Currents project, then configure credentials through environment variables (
CURRENTS_RECORD_KEY,CURRENTS_PROJECT_ID). - Replicate the framework + CI integration pattern shown in the source docs for this use case (reporter/plugin wiring, CI command, and build ID strategy).
- Run the same local commands from the source docs first, then execute the CI variant to confirm dashboard reporting works end-to-end.
- After validation, adapt the pattern to your repository structure while keeping secrets in env vars and preserving the same reporting/orchestration flow.
- Add a README
- Right now there’s no README in the repo root; without the blog post, it’s not self-explanatory.
- Make
npm test“just work” by starting the server automatically- Add Playwright
webServerconfig (or astart-server-and-testscript) so users don’t need two terminals or guess that port 5173 must be running. (Today tests assumehttp://localhost:5173is already up.)
- Add Playwright
- Add a “generate HTML coverage report” step
- The repo collects raw coverage JSON, but doesn’t include a script/tooling to convert it into HTML/LCOV (e.g., v8-to-istanbul + nyc) even though that’s the typical “next step” users expect.
- Reformat source files
- Many files are committed as single-line/minified (package.json, config, JS/TS), which makes copying/learning harder.
- Add a CI workflow
- A simple GitHub Actions workflow running Chromium tests would make it easier to validate the example and reuse it.
- (Optional) Clarify relation to Currents
- This repo is “for the blog article”; it doesn’t show uploading coverage to Currents. A README note like “this repo demonstrates collection; see X for Currents ingestion” would prevent confusion.
- No source markdown files were found for this repository.
- Total tracked files copied: 17
- Source repository does not include a root
README.md. - Path mapping:
content-map.md