Skip to content

How typed tests build the renderer bridge stub and mock functions without any #293

Closed

Description

@jtklein-agents

Question

Converted tests must have zero diagnostics under --noImplicitAny, and lint forbids explicit any in .ts. Tests assign partial objects to window.rendererBridge (for example { getExampleFiles, parseAlignment }), and src/test/setup.ts and src/test/storeBridge.ts build stubs from partial input. How does a test express a partial RendererBridge and a typed vi.fn: a shared helper in src/test/ that accepts Partial<RendererBridge>, a cast at each site, or a widened type on the window property for tests only? Which form does the spec require of every converted file?

Activity

  1. added
    wayfinder:grilling
    on Nov 22, 2026
  2. jtklein-agents commented on Nov 22, 2026

    @jtklein-agents
    OwnerAuthor

    Resolution

    One bridge helper, plain mocks, casts at the site, no blanket suppressions.

    • Bridge: every test installs its bridge through one function in src/test/ that takes Partial<RendererBridge> and holds the single cast to the full type. No test assigns to window.rendererBridge directly. This replaces 66 direct assignments in 38 files. Partial<RendererBridge> still checks each method a test supplies. Rejected: a cast at each site (checks much less) and widening the Window declaration (loosens production code).
    • stubBridge: takes the same Partial<RendererBridge> and calls that helper, so one place writes to window.rendererBridge.
    • Mocks: vi.fn() plain. A type argument only where the test reads the mock's calls or results and tsc asks for it (16 such reads today).
    • Partial fixtures for stores: cast at the site (new Run( {} as RunList, 7 )), as CODING_STANDARDS.md already says for injects. No shared fixture builders.
    • Suppressions: converted tests carry no @ts-nocheck and no @ts-ignore. @ts-expect-error with a one-line reason is allowed only where a test passes a wrong type on purpose to exercise a runtime guard (for example new Run( null, 1 )). The 64 @ts-nocheck headers go.
    • Left to the spec: the helper's name, and adding these rules to CODING_STANDARDS.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

wayfinder:grilling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions