Skip to content

test(web): gate the web engine at 100% coverage (vitest v8 + CI)#10

Merged
scumunna merged 3 commits into
mainfrom
test/web-engine-coverage
Jun 23, 2026
Merged

test(web): gate the web engine at 100% coverage (vitest v8 + CI)#10
scumunna merged 3 commits into
mainfrom
test/web-engine-coverage

Conversation

@scumunna

Copy link
Copy Markdown
Owner

Follows the native coverage work (#9), now for the web side: a 100% coverage gate on the pure TypeScript engine (web/src/engine), the faithful port of BidLabCore.

Result

vitest run --coverage, scoped to src/engine:

Metric Before After
Statements 88.4% 100% (396/396)
Branches 69.7% 100% (204/204)
Functions 89.8% 100% (88/88)
Lines 93.6% 100% (345/345)

Full web suite: 180 tests (was 147), all passing.

How it's enforced

  • @vitest/coverage-v8 with a coverage block in web/vite.config.ts: include: ['src/engine/**'], thresholds: { statements/branches/functions/lines: 100 }. npm run test:coverage fails locally if any engine line, branch, or function is uncovered.
  • New .github/workflows/web.yml runs typecheck + the coverage gate on every push to main and PR touching web/** (static npm steps only — no untrusted input).

What's tested

src/engine/coverage.test.ts is a boundary suite mirroring the Swift EdgeCoverageTests: divide-by-zero guards (→ Infinity/0), distribution special cases (p==0/1, sd==0, the normalQuantile tails, lgamma reflection), empty-input returns, MarketResult/PacedFlightResult getters, both market models and auction types, and the runMarket floor-loss/competition-loss/budget-bind branches.

Two source tweaks (mirror #9)

  • pacedFlight.ts: dropped a dead winRate ternary (intervalOpportunities is Math.max(1, …), always ≥ 1).
  • analytics.ts: kept the defensive se > 0 guard in power() (unreachable since baselineRate ∈ (0,1)), marked /* v8 ignore next */.

Scope

The gate is the pure engine (the credibility core). The React components are UI and are not part of this gate — a separate effort if you want component/DOM coverage later.

🤖 Generated with Claude Code

Stephen Umunna and others added 3 commits June 22, 2026 08:27
Mirrors the Swift BidLabCore cleanup (#9). PacedFlight computed winRate as
`intervalOpportunities > 0 ? ... : 0`, but intervalOpportunities is
`Math.max(1, ...)`, so the guard is dead; divide directly. Analytics.power keeps
its defensive `se > 0` guard (se is always > 0 because baselineRate is in (0,1)),
marked `/* v8 ignore next */` since it is unreachable by construction.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add @vitest/coverage-v8 with coverage scoped to src/engine at 100% thresholds
(statements/branches/functions/lines), a coverage.test.ts boundary suite that
completes branch coverage (divide-by-zero guards, p==0/1, sd==0, the normal-
quantile tails, empty inputs, Result getters), a test:coverage script, and a Web
CI workflow running typecheck + the coverage gate on PRs and pushes touching
web/. The engine reports 100% on all four metrics; the full suite is 180 tests.
The gate is the pure engine; components are UI and covered separately.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vitest v4's CoverageOptions type no longer includes `all`, so `tsc --noEmit`
(the typecheck CI step) rejected vite.config.ts. `include: ['src/engine/**']`
already scopes coverage and every engine file is imported by a test, so the 100%
result is unchanged (396/396 statements, 204/204 branches, 88/88 functions,
345/345 lines). Verified locally with both `npm run typecheck` and the gate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@scumunna scumunna merged commit f39729c into main Jun 23, 2026
2 checks passed
@scumunna scumunna deleted the test/web-engine-coverage branch June 23, 2026 18:05
scumunna pushed a commit that referenced this pull request Jun 23, 2026
…0 web)

#9 raised the native suite to 5,271 checks and #10 the web suite to 180; update
the README and ACCEPTANCE.md to match, and add the CI coverage-gate story (web
100%, native 100% of reachable code). ACCEPTANCE.md's web engine-suite row now
includes the added boundary tests (47 -> 80).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant