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
[coverage] Support collecting and formatting Web (V8 / Chrome) coverage reports #2434
Currently, package:coverage utilities (such as test_with_coverage, collect_coverage, and format_coverage) are designed around the Dart VM Service API and gather coverage metrics exclusively from Dart VM isolates.
When running tests targeting web or browser platforms (e.g. dart test -p chrome), package:test collects V8 JavaScript JSON coverage files (e.g. my_test.dart.chrome.json). However:
dart run coverage:test_with_coverage does not support collecting or orchestrating web/Chrome test runs.
Running collect_coverage against a -p chrome test run produces an empty VM coverage file ({"type":"CodeCoverage","coverage":[]}).
Collecting code coverage across full-stack applications (where backend Shelf SSR runs on the VM and frontend components run in V8) requires manual multi-step compilation and formatting.
It would be fantastic if package:coverage (test_with_coverage and format_coverage) could natively support collecting, parsing, and unifying Web/V8 JS coverage data alongside Dart VM coverage into a single LCOV report.
Related context / demand: See also #471 where developers run into hangs attempting to use --coverage with -p chrome.
Partial progress on this in #2448, which covers the first two points: test_with_coverage can now orchestrate web/Chrome runs via -p chrome, and those runs produce real coverage instead of an empty {"type":"CodeCoverage","coverage":[]}.
The third point — unifying web and VM coverage into a single LCOV report, for the full-stack case — is deliberately not in that PR, so I've marked it Towards rather than Fixes. Two things I learned while scoping it, for whoever picks it up:
It requires giving up function coverage. Merging means running both platforms in one dart test --coverage invocation (the VM-service pause/resume flow can't be combined with the browser flow in a single run). dart test --coverage emits line coverage only — verified: no funcHits/funcNames in its output even for VM suites. So a unified mode would have to reject --function-coverage.
The merge semantics need a deliberate decision. Web coverage is measured on compiled JavaScript, so the two platforms track genuinely different line sets: code the compiler tree-shakes cannot be reported as uncovered at all. Merging takes the union, so a line covered on the VM but absent from the web build reads as covered. For "is this code tested anywhere" — the full-stack question — that is the right answer. For "is my frontend actually tested" it hides platform gaps, and --fail-under would gate on the union.
Mechanically the change looks small: package:test already accepts -p vm,chrome and writes both .vm.json and .chrome.json into one directory, and HitMap.parseFiles already merges them. The design questions above are the real work.
Activity
kevmoo commentedon Aug 13, 2026
Partial progress on this in #2448, which covers the first two points:
test_with_coveragecan now orchestrate web/Chrome runs via-p chrome, and those runs produce real coverage instead of an empty{"type":"CodeCoverage","coverage":[]}.The third point — unifying web and VM coverage into a single LCOV report, for the full-stack case — is deliberately not in that PR, so I've marked it
Towardsrather thanFixes. Two things I learned while scoping it, for whoever picks it up:It requires giving up function coverage. Merging means running both platforms in one
dart test --coverageinvocation (the VM-service pause/resume flow can't be combined with the browser flow in a single run).dart test --coverageemits line coverage only — verified: nofuncHits/funcNamesin its output even for VM suites. So a unified mode would have to reject--function-coverage.The merge semantics need a deliberate decision. Web coverage is measured on compiled JavaScript, so the two platforms track genuinely different line sets: code the compiler tree-shakes cannot be reported as uncovered at all. Merging takes the union, so a line covered on the VM but absent from the web build reads as covered. For "is this code tested anywhere" — the full-stack question — that is the right answer. For "is my frontend actually tested" it hides platform gaps, and
--fail-underwould gate on the union.Mechanically the change looks small:
package:testalready accepts-p vm,chromeand writes both.vm.jsonand.chrome.jsoninto one directory, andHitMap.parseFilesalready merges them. The design questions above are the real work.feat(coverage): support web coverage reports in test_with_coverage (#…