chore(coverage): istanbul instrumentation for the trace viewer and html reporter - #42785
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…ml reporter Instrument the sources under packages/ with a vite plugin behind PWTEST_COVERAGE and record the coverage of the trace viewer and html reporter pages through tracing. The stable test runner is rolled to 1.64.0-alpha-2026-09-18, the first with the tracing coverage, so the html reporter tests need no collector of their own. The trace viewer service worker has its own global and its own counters. The instrumented build serves them from a /coverage route of the worker, gated on the __PW_COVERAGE__ define that the istanbul plugin sets, so a normal build carries neither the route nor a counter reference. The tests fold the worker delta into window.__coverage__ through the page before the page is collected. Only applyPlaywrightAttributes in the snapshot renderer is skipped with an istanbul hint, since its source is stringified into the snapshot where the counters do not exist. The product feature does not follow for now. Only Chromium exposes a service worker execution context, Firefox's juggler has no service worker targets and WebKit's automation session attaches to page and frame targets only, so both would need a browser patch. Worker counters also die with every termination and there is no unload hook to stash them, so a generic collector would be Chromium-only and lossy.
ab56b7e to
c19de45
Compare
The plugin imports it directly instead of resolving it at run time, and the install instructions go away.
…strument The schema defaults are stage-4 syntax that the parser enables anyway, so only the typescript and jsx plugins remain and the local declarations go away.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The plugin no longer checks the environment or defines __PW_COVERAGE__, the worker's coverage route answers only when counters exist.
Test results for "tests 1"5 flaky52020 passed, 1250 skipped Merge workflow run. |
Test results for "MCP"3 failed 8689 passed, 1474 skipped Merge workflow run. |
🟡 Two known flakes, one I can't clearHi, I'm the Playwright bot and I took a look at the failing MCP run. The two DetailsThis PR is coverage instrumentation. The istanbul vite plugin is registered only when Pre-existing flake / infra
Uncertain
Triaged by the Playwright bot - agent run |
07f1a61
into
microsoft:main
Summary
PWTEST_COVERAGEinstruments the sources underpackages/, so the trace viewer and html reporter tests report their own coverage through tracing/coverageroute that only exists in instrumented buildsWhy not
vite-plugin-istanbul: it runs after the TypeScript and JSX transforms, so the recorded positions refer to the emitted code and only a report stage that applies the embeddedinputSourceMapcan map them back. Our reporter does not, so the plugin here instruments the original sources instead.