Skip to content

test: expand core coverage, starting with Game/index.ts extraction targets #134

Description

@nodots

Problem

Core test coverage is low, and it is lowest precisely on the code the Game/index.ts decomposition (#132) is about to move. Extracting untested methods means the test suite cannot catch extraction regressions where the risk is highest.

Measured baseline (COVERAGE=1 npx jest, 2026-07-15):

Scope Stmts Branch Funcs Lines
core (all files) 56.5% 40.9% 56.8% 57.3%
Game/index.ts 53.7% 45.6% 61.2% 55.5%

Uncovered ranges in Game/index.ts map directly to extraction targets:

Method(s) Approx. lines Extraction target module (#132)
roll internals 666–831 turnFlow.ts
switchDice 1016–1117 turnFlow.ts
executeAndRecalculate ~1542 turnFlow.ts
restoreState 1962–1993 lifecycle.ts
canOfferDouble / double 2038–2095 cube.ts
acceptDouble / refuseDouble 2115–2208 cube.ts
resign 2284–2329 cube.ts
confirmTurnWithRobotAutomation 2356–2377 robot.ts
undoLastInActivePlay / canUndoActivePlay 2467–2489 undo.ts

Goal

Raise coverage on the methods being extracted to a level where the extraction is verifiably behavior-preserving, then lift core coverage more broadly. Approach: characterization tests first — capture current behavior as tests before the code moves, so a passing suite after extraction is proof of equivalence.

Scope (phased, ordered to unblock #132)

Phase A — safety net for the decomposition (do before the matching #132 phase)

Phase B — broader core lift (after / independent of #132)

  • Raise core coverage to 75% (statements, branches, functions, lines) from the current ~57% line / ~41% branch.
  • Add a coverageThreshold gate of 75% to jest.config.js (currently coverage is opt-in via COVERAGE=1, no threshold) so coverage cannot regress silently. The gate lands once coverage clears 75% — adding it earlier would fail the suite immediately at the current ~41% branch. Interim option: ratchet the threshold up as coverage rises rather than one jump at the end.
  • Identify and cover other low-coverage core areas surfaced by the full report (e.g. debugSingleGame.ts ~54%, and the sub-50% files in the full run).

Delivery

Notes / constraints

  • Coverage is gated behind COVERAGE=1 in jest.config.js (reporters: text, lcov). Full report: run COVERAGE=1 npx jest from packages/core.
  • Current baseline suite is green (448 passed / 12 skipped, exit 0) — new tests must not depend on that changing.
  • Characterization tests should assert on real produced game state, not re-implement game logic.
  • Part of the Game/index.ts remediation epic; coordinate phase ordering with refactor: split Game/index.ts god file into cohesive modules #132.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions