Coverage: what the measurements leave out #407

Closed
opened 2026-11-06 19:51:46 -08:00 by rays · 4 comments
Owner

What the coverage runs (#390, #394) do not count, so their numbers read lower than the tests are: the page's unit tests (page-unit.ts) and native-bridge.ts run in Node and are not measured, so iconMatches, nextOffset and native.ts read as untested though they are; a page's coverage is lost when it navigates away (the sign-in redirect and the new-version reload read as untested though tests run them); the Signals browser tests skip themselves; and the coverage container runs the Rust tests on SQLite only, so Postgres's own paths (db.rs) are never measured. The cargo suite's totals also hold the tests' own code (#394).

To do:

  • measure the Node page tests with NODE_V8_COVERAGE into the same page report
  • keep a page's coverage across a navigation (take it before each, or per document)
  • run the Signals tests and the Rust tests on Postgres (the _test database) in coverage runs
  • leave the tests' own code out of the cargo totals

Seen with the coverage of both suites merged line by line (cargo: sh scripts/coverage.sh, browser: sh scripts/coverage.sh api; reports in target/coverage/cargo, api and page; #390, #394), as of 2026-11-07. A test added here shows in Grafana's Coverage row at the next run.

What the coverage runs (#390, #394) do not count, so their numbers read lower than the tests are: the page's unit tests (page-unit.ts) and native-bridge.ts run in Node and are not measured, so `iconMatches`, `nextOffset` and native.ts read as untested though they are; a page's coverage is lost when it navigates away (the sign-in redirect and the new-version reload read as untested though tests run them); the Signals browser tests skip themselves; and the coverage container runs the Rust tests on SQLite only, so Postgres's own paths (db.rs) are never measured. The cargo suite's totals also hold the tests' own code (#394). To do: - measure the Node page tests with NODE_V8_COVERAGE into the same page report - keep a page's coverage across a navigation (take it before each, or per document) - run the Signals tests and the Rust tests on Postgres (the `_test` database) in coverage runs - leave the tests' own code out of the cargo totals Seen with the coverage of both suites merged line by line (cargo: `sh scripts/coverage.sh`, browser: `sh scripts/coverage.sh api`; reports in target/coverage/cargo, api and page; #390, #394), as of 2026-11-07. A test added here shows in Grafana's Coverage row at the next run.
rays added the enhancement label 2026-11-06 19:51:46 -08:00
Author
Owner

Done in f6ba08d: the page's Node tests (page-unit.ts, native-bridge.ts) are measured into the page report (73.3% to 80.0% of 3,043 lines; native.ts 93/120); the coverage container's cargo tests run on Postgres from IPX_TEST_DATABASE_URL (checked with sh scripts/coverage.sh ipx-directory); tests/ files are out of the cargo totals, inline mod tests cannot be on stable; the Signals browser tests run in coverage runs since 980fbc3 (#398). Left open for the one item not done: a page's coverage across a navigation. The fixture already passes resetOnNavigation: false, and whether the sign-in redirect and the new-version reload still lose their lines needs a run that compares one test with and without a navigation; the second browser contexts the tests open (piper's pages) are not measured at all either, since the fixture records only page.

Done in f6ba08d: the page's Node tests (page-unit.ts, native-bridge.ts) are measured into the page report (73.3% to 80.0% of 3,043 lines; native.ts 93/120); the coverage container's cargo tests run on Postgres from IPX_TEST_DATABASE_URL (checked with sh scripts/coverage.sh ipx-directory); tests/ files are out of the cargo totals, inline mod tests cannot be on stable; the Signals browser tests run in coverage runs since 980fbc3 (#398). Left open for the one item not done: a page's coverage across a navigation. The fixture already passes resetOnNavigation: false, and whether the sign-in redirect and the new-version reload still lose their lines needs a run that compares one test with and without a navigation; the second browser contexts the tests open (piper's pages) are not measured at all either, since the fixture records only `page`.
Author
Owner

Checked the navigation item against the page report of f6ba08d: it is real. The test 'a new version reloads the page…' runs reloadKeepingPlace (events.ts 111-113), yet its lines have 0 hits, while checkVersion before it has 1 and takeReopen after the reload 206. resetOnNavigation: false does not keep what the old document ran: the reload discards that document's script, and its coverage with it. A fix has to take the coverage before the document goes, e.g. a CDP session per page calling Profiler.takePreciseCoverage on Page.frameRequestedNavigation and when the page closes, merged into the report; it also needs the second contexts' pages (piper's) recorded, which the fixture does not do now.

Checked the navigation item against the page report of f6ba08d: it is real. The test 'a new version reloads the page…' runs reloadKeepingPlace (events.ts 111-113), yet its lines have 0 hits, while checkVersion before it has 1 and takeReopen after the reload 206. resetOnNavigation: false does not keep what the old document ran: the reload discards that document's script, and its coverage with it. A fix has to take the coverage before the document goes, e.g. a CDP session per page calling Profiler.takePreciseCoverage on Page.frameRequestedNavigation and when the page closes, merged into the report; it also needs the second contexts' pages (piper's) recorded, which the fixture does not do now.
Author
Owner

Tried and reverted: holding each document request in a page.route while the coverage so far is taken (stopJSCoverage, then startJSCoverage) and then letting it go on. Routing every request broke the live updates' stream; routing only /, /login and /admin made every test time out at a minute, the navigation stalled while coverage was taken inside the route. So the CDP route in the comment above (Profiler.takePreciseCoverage from a session of the test's own, outside Playwright's routing) is the one left to try.

Tried and reverted: holding each document request in a page.route while the coverage so far is taken (stopJSCoverage, then startJSCoverage) and then letting it go on. Routing every request broke the live updates' stream; routing only /, /login and /admin made every test time out at a minute, the navigation stalled while coverage was taken inside the route. So the CDP route in the comment above (Profiler.takePreciseCoverage from a session of the test's own, outside Playwright's routing) is the one left to try.
Author
Owner

Done in 07923d6, the last item. Every page a test opens, its own and the second contexts' (piper's, opal's), records through a CDP session of the fixture's own, and each document stops at a breakpoint in a beforeunload listener the fixture adds, where its coverage is taken before it goes; a page or context is taken again as it closes. The CDP route as first proposed did not work either: Profiler.takePreciseCoverage on Page.frameRequestedNavigation came after the old document had gone, and holding the document request with Fetch held the take up behind it (the renderer answers nothing while a navigation waits), the same stall as page.route. With the breakpoint, the new-version test's reloadKeepingPlace (events.ts 111-113) has its hit, and the whole suite in coverage mode passes (108, 6 Signals skipped without IPX_SIGNALS_TESTS): page lines 80.0% to 84.5%, in Grafana.

Done in 07923d6, the last item. Every page a test opens, its own and the second contexts' (piper's, opal's), records through a CDP session of the fixture's own, and each document stops at a breakpoint in a beforeunload listener the fixture adds, where its coverage is taken before it goes; a page or context is taken again as it closes. The CDP route as first proposed did not work either: Profiler.takePreciseCoverage on Page.frameRequestedNavigation came after the old document had gone, and holding the document request with Fetch held the take up behind it (the renderer answers nothing while a navigation waits), the same stall as page.route. With the breakpoint, the new-version test's reloadKeepingPlace (events.ts 111-113) has its hit, and the whole suite in coverage mode passes (108, 6 Signals skipped without IPX_SIGNALS_TESTS): page lines 80.0% to 84.5%, in Grafana.
rays closed this issue 2026-11-07 06:37:58 -08:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rays/ipx#407