You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: CoverageReporter throws TypeError on empty branch locations in lcov generation #44113
Enable trace with _coverage: true and configure the coverage reporter in playwright.config.ts.
Instrument code that contains an if statement without an else branch (or any branch structure where Istanbul leaves implicit branch locations empty {}).
Run test with @playwright/test.
Expected behavior
CoverageReporter should safely read the line number and generate lcov.info without crashing.
Actual behavior
CoverageReporter crashes with:
TypeError: Cannot read properties of undefined (reading 'line')
When an implicit branch has an empty location object {} in Istanbul's branch.locations, accessing location.start.line throws because location.start is undefined.
Additional context
I have reproduced the issue and have a local fix ready with regression tests. Please assign this to me so I can open the pull request.
Hi, I'm the Playwright bot and I reproduced this on macOS.
Reproduced on current main (826ce42b8664ea940424e77ce51f1cdf96dcd37f, 1.66.0-next) in Chromium, Firefox, and WebKit. The reporter reads location.start.line before it can use the enclosing branch's line number, so an empty location throws.
#44114 fixes the crash at beb4d939a4d57cb2416863383d3876fc4f130011. My independent reproduction passes with that fix on all three browsers. Its regression test also fails without the source change and passes with it. No separate fix is needed.
Reproduction and checks
I extended should aggregate coverage with the coverage reporter in tests/playwright-test/coverage.spec.ts, removing start and end from an existing branch location before serializing the coverage data. The test checks that lcov.info contains BRDA:2,0,1,0.
Independent reproduction on #44114, same Chromium and Firefox, WebKit 27.2 (r2393), headless
Passes in all three
PR's regression test applied to main without its source fix
Fails with the reported TypeError
PR's complete coverage-reporter test file
3 pass per browser
Related coverage-collection tests, tests/library/coverage.spec.ts
39 pass across all three browsers
Neighboring reporter lifecycle and attachment tests
19 pass; browser-independent
npm run build, then npm run flint on the PR
Pass
Merge with current main
No conflicts
I used Node.js 24.22.2. I did not test the reported 1.51.0 or headed mode because the exact crash reproduces on current main. Initial setup attempts failed because dependencies and browser binaries were absent; those passed after installing the pinned dependencies and browsers.
The PR's only reported GitHub check is the successful CLA check; no test CI jobs have run. GitHub reports its merge state as blocked, so this local verification does not bypass the repository's merge requirements.
Activity
halcyon-past commentedon Nov 14, 2026
I have submitted a pull request with the fix and regression coverage in #44114.
microsoft-playwright-automation commentedon Nov 16, 2026
microsoft-playwright-automation commentedon Nov 16, 2026
Hi, I'm the Playwright bot and I reproduced this on macOS.
Reproduced on current main (
826ce42b8664ea940424e77ce51f1cdf96dcd37f, 1.66.0-next) in Chromium, Firefox, and WebKit. The reporter readslocation.start.linebefore it can use the enclosing branch's line number, so an empty location throws.#44114 fixes the crash at
beb4d939a4d57cb2416863383d3876fc4f130011. My independent reproduction passes with that fix on all three browsers. Its regression test also fails without the source change and passes with it. No separate fix is needed.Reproduction and checks
I extended
should aggregate coverage with the coverage reporterintests/playwright-test/coverage.spec.ts, removingstartandendfrom an existing branch location before serializing the coverage data. The test checks thatlcov.infocontainsBRDA:2,0,1,0.Minimal equivalent configuration:
Test:
TypeErrorin all threeTypeErrortests/library/coverage.spec.tsnpm run build, thennpm run flinton the PRI used Node.js 24.22.2. I did not test the reported 1.51.0 or headed mode because the exact crash reproduces on current main. Initial setup attempts failed because dependencies and browser binaries were absent; those passed after installing the pinned dependencies and browsers.
The PR's only reported GitHub check is the successful CLA check; no test CI jobs have run. GitHub reports its merge state as blocked, so this local verification does not bypass the repository's merge requirements.
fix(coverage): handle empty branch locations in lcov generation (micr…