mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 16:02:26 +00:00
4.0 KiB
4.0 KiB
Playwright Function Coverage + Console Diagnostics
Use this workflow to measure how much of bitvid's runtime code is exercised by E2E Playwright tests and to export browser console/page errors for triage.
Run
npm run test:e2e:coverage
This command:
- Builds
dist/ - Runs
tests/e2eon Chromium with browser JS coverage enabled - Captures browser
consoleandpageerroroutput for every test - Generates aggregate reports
Artifacts
artifacts/playwright-coverage/raw/*.json- Per-test raw coverage + console/page-error logs
artifacts/playwright-coverage/function-coverage-summary.json- Machine-readable function coverage report
artifacts/playwright-coverage/function-coverage-summary.md- Human-readable summary with coverage percentage and low-coverage files
artifacts/playwright-coverage/console-log-summary.json- Full exported console/page-error logs
artifacts/playwright-coverage/console-issues.log- Grouped issue signals for fast triage
Notes
- Coverage is captured from Chromium runtime execution (
page.coverage), then combined with static function estimates for source files injs/andtorrent/. - Firefox coverage is not included in this report because Playwright JS coverage is Chromium-only.
- For reliability patterns while increasing coverage, see
docs/testing/high-quality-playwright-tests.md.
Current Baseline (2026-02-22)
From a full real run (npm run test:e2e:coverage) on 2026-02-22:
- E2E result:
40 passed - Function coverage:
29.9%(2863/9576) - Loaded source files:
297/313 - Console logs:
72 - Console error-like entries:
4 - Page errors:
0
Primary issue groups captured:
404 Not Foundresource errors (2 occurrences)- Forced decrypt-timeout warning in diagnostics test (expected by test, 1 occurrence)
- CORS-blocked
.torrentfetch in webseed playback test (1 occurrence) net::ERR_FAILEDin webseed playback test (1 occurrence)- WebSocket tracker handshake failure for
wss://tracker.btorrent.xyz/(1 occurrence)
Recent high-impact coverage improvements:
js/nostr/commentEvents.js:90.91%(20/20)js/nostr/reactionEvents.js:78.57%(11/14)js/nostr/publishHelpers.js:79.41%(27/34)js/nostr/sessionActor.js:79.41%(27/34)
Integration Rules For Agents
- For
tests/e2e/*.spec.ts, import fromtests/e2e/helpers/instrumentedTest.tsso coverage/log capture stays enabled. - For harness-based tests, use
tests/e2e/helpers/bitvidTestFixture.ts(it already includes auto-capture). - Keep coverage runs Chromium-only when collecting percentages (
page.coverageis Chromium-specific). - Do not remove
playwright.config.tsglobal setup (tests/e2e/helpers/playwrightCoverageGlobalSetup.ts), which resets raw coverage artifacts. - Use
npm run test:e2e:coverage:reportonly after a prior coverage-enabled run; it reads existing raw artifacts.
How To Improve Coverage
Priority order for fastest gains:
- Add E2E for high-function files currently at
0%but loaded:- Start with
js/nostr/commentEvents.js,js/nostr/reactionEvents.js,js/nostr/publishHelpers.js,js/nostr/sessionActor.js.
- Start with
- Add deterministic DM coverage lane in E2E harness:
- Exercise NIP-04 and NIP-44 decrypt/encrypt flows through UI and harness hooks.
- Add upload + publish deep-path tests:
- Validate URL-only, magnet-only, and dual-source publish paths with assertions on fallback behavior.
- Add negative-path assertions that currently only surface in console:
- Explicitly assert/handle CORS/torrent fetch failures and tracker handshake failures.
- Keep tests routed through test-harness APIs:
- Prefer
setTestRelays,setSignerDecryptBehavior, and seeded relay events over live-network dependence.
- Prefer
Suggested Quality Gates
- Track
functionCoveragePcttrend in CI artifacts per PR. - Add a soft warning threshold first (for example
>=30%), then ratchet upward as flaky paths are stabilized. - Fail PRs only after baseline is stable across multiple runs.