Skip to content

Add web coverage support - #3182

Open
Komoszek wants to merge 5 commits into
masterfrom
feature/implement-coverage-for-web
Open

Add web coverage support#3182
Komoszek wants to merge 5 commits into
masterfrom
feature/implement-coverage-for-web

Conversation

@Komoszek

@Komoszek Komoszek commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Closes #3121

What was implemented

patrol test --coverage now works on the web platform. Coverage was previously
collected only on Android/iOS from the Dart VM service; the browser has no Dart VM,
so web runs produced no report. This change collects the browser's native JavaScript
coverage during the Playwright run and maps it back to Dart sources, producing the
same coverage/patrol_lcov.info LCOV report as the mobile flow.

Notable differences, surfaced in --help and the docs:

  • Web reports covered / uncovered only, without the per-line hit counts.
  • Every non-debug build error out with --coverage. It previously just silently skipped coverage collection

How it works

During a web test run the Playwright runner records Chrome's native JavaScript
coverage (with source maps) for each test. Afterwards the CLI reads that data,
maps the covered JS back to the original Dart lines through the source maps, and
writes the same LCOV report as on mobile. The VM and web paths share the report
formatting and package/workspace filtering, so the output is consistent across
platforms.

Results

Ran the existing text_fields_test.dart on both an Android emulator and Chrome with
--coverage. Both produce a valid report over the same file set; below is the
coverage of the exercised widget (text_fields_screen.dart):

Platform Lines Covered %
Android (VM) 17 17 100%
Web (V8 + source maps) 21 20 95.2%

The two agree on the widget body. The gap is the documented behaviour: web is binary
covered/uncovered (no hit counts) and the toolchains differ slightly on which lines
are "coverable" — web instruments a few more lines (e.g. the field initializer and the
const constructor, which it marks uncovered) that the VM omits.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@github-actions github-actions Bot added docs Concerns doc comments, READMEs, or docs package: patrol Related to the patrol package (native automation, test bundling) package: patrol_cli Related to the patrol_cli package labels Jul 21, 2026
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

🚀 Preview Deployment Ready!

Preview URL: https://pr-3182-patrol-docs.vercel.app


Latest Deployment

  • Commit: f01da95
  • Branch: feature/implement-coverage-for-web
  • Triggered by: @Komoszek
  • Deployed at: 2026-07-28 12:19:17 UTC

This preview URL is stable and will be updated with each new commit to this PR.

@Komoszek
Komoszek marked this pull request as ready for review July 22, 2026 00:04
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@Komoszek
Komoszek force-pushed the feature/implement-coverage-for-web branch from 7e66566 to f01da95 Compare July 28, 2026 12:17

@pdenert pdenert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the comments are exaggerated descriptive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Concerns doc comments, READMEs, or docs package: patrol_cli Related to the patrol_cli package package: patrol Related to the patrol package (native automation, test bundling)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] patrol test --coverage crashes before Playwright starts with Bad state: No element

2 participants