Skip to content

Type-check tests in CI; pass penanceId in tests; test penance turn order - #78

Merged
96jonesa merged 1 commit into
masterfrom
andy/claude/test-typecheck
Oct 28, 2026
Merged

96jonesa merged 1 commit into
masterfrom
andy/claude/test-typecheck

Conversation

@96jonesa

Copy link
Copy Markdown
Owner

Closes #77.

Problem

#39 added a penanceId parameter to the RunnerPenance and HealerPenance constructors, but 62 calls in test/ still passed 4 arguments. penanceId was undefined in every penance a test built directly, every turn-order comparator computed NaN, and sort kept insertion order. So the penance turn order had no coverage: reversing or deleting the sorts left all tests passing.

Nothing caught this because vitest strips types without checking them. tsc couldn't check test/ either: test/tsconfig.json inherits target: es2016 with no module setting, which means moduleResolution: classic. That mode only looks for vitest.ts / vitest.d.ts files in parent folders and never looks in node_modules.

Changes

  • test/tsconfig.json: set module: esnext, moduleResolution: bundler (how Vite resolves imports), skipLibCheck and noEmit. The root tsconfig.json is unchanged, so built/ is identical.
  • 62 calls: pass penanceId = id. No test puts a runner and a healer in the same game, so the ids don't collide.
  • New tests:
    • tick › penance take turns in penanceId order, not insertion order (records tick() call order)
    • tick › red egg splash ties go to the higher penanceId
    • Cannon.tick › targets the lower penanceId when runners are otherwise tied
  • npm run typecheck (tsc -p test) added, run in CI before the tests, and documented in the README.

Verified

  • npm run typecheck passes, all 295 tests pass, and a rebuild leaves built/ unchanged.
  • Each sort was broken on purpose to confirm a test catches it:
Change Result
tickPenance order reversed / sort deleted 1 test fails
Splash tie-break reversed / removed 1 test fails
Cannon tie-break reversed / removed 1 test fails
Splash outer sort reversed all pass (see below)
A test call missing penanceId typecheck reports TS2554

The outer sort in applyRedEggSplashes only decides which landing red egg uses the Math.random() splash rolls first. With forced splash counts the outcome doesn't depend on it, and with random splashes it only changes which egg gets which roll, so there's no deterministic behaviour to pin.

🤖 Generated with Claude Code

#39 added a penanceId constructor parameter to RunnerPenance and
HealerPenance, but 62 test calls still passed the old four arguments.
penanceId was undefined in every test-built penance, every penanceId
comparator returned NaN, and sort kept insertion order, so turn order
was untested: reversing or deleting the sorts left all tests passing.
Nothing caught it because vitest does not type-check, and
test/tsconfig.json inherited classic module resolution, which cannot
find vitest in node_modules.

- test/tsconfig.json: module esnext, moduleResolution bundler,
  skipLibCheck, noEmit
- pass penanceId (= id) in all 62 calls
- tests for tickPenance order, the red egg splash tie-break and the
  cannon target tie-break
- npm run typecheck, run in CI

Closes #77

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@96jonesa
96jonesa merged commit 1874855 into master Oct 28, 2026
1 check passed
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.

tests never set penanceId, so penance turn order is untested; tests aren't type-checked

1 participant