You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How typed tests build the renderer bridge stub and mock functions without any #293
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?
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.
Activity
jtklein-agents commentedon Nov 22, 2026
Resolution
One bridge helper, plain mocks, casts at the site, no blanket suppressions.
src/test/that takesPartial<RendererBridge>and holds the single cast to the full type. No test assigns towindow.rendererBridgedirectly. 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 theWindowdeclaration (loosens production code).stubBridge: takes the samePartial<RendererBridge>and calls that helper, so one place writes towindow.rendererBridge.vi.fn()plain. A type argument only where the test reads the mock's calls or results andtscasks for it (16 such reads today).new Run( {} as RunList, 7 )), asCODING_STANDARDS.mdalready says for injects. No shared fixture builders.@ts-nocheckand no@ts-ignore.@ts-expect-errorwith a one-line reason is allowed only where a test passes a wrong type on purpose to exercise a runtime guard (for examplenew Run( null, 1 )). The 64@ts-nocheckheaders go.CODING_STANDARDS.md.