Relationships
#2098 createModelTestContext mock Logger has .warn() but real runtime has .warning()
Opened by aaronge · 9/10/2026· Shipped 9/10/2026
Description
createModelTestContext() from jsr:@swamp-club/swamp-testing returns a context.logger implementing debug/info/warn/error/fatal. The real extension-model runtime documents its logger levels as trace/debug/info/warning/error/fatal (LogTape convention) — i.e. the real method is .warning(), not .warn().
An extension model that correctly types its context as { logger: { warning(message: string, properties?: Record<string, unknown>): void } } (matching the real runtime) fails to type-check when passed the mock's MethodContext from createModelTestContext(), because the mock's Logger type has no warning property at all — only warn. If the type error is bypassed, calling .warning(...) against the mock throws TypeError: ... .warning is not a function at test runtime.
Confirmed present in the two most recent published versions: 0.20260824.32 and the current latest 0.20260828.33.
Steps to Reproduce
- In an extension model, declare a method whose
executecontext type requireslogger.warning(message, properties?)(matching documented real-runtime usage). - Call
context.logger.warning("some message", { foo: "bar" })insideexecute. - Write a
_test.tsthat imports the model and callsmodel.methods.<method>.execute({}, context)wherecontextcomes fromcreateModelTestContext(). - Run
deno checkon the test file.
Expected: type-checks cleanly, since the mock context should satisfy the same interface the real runtime does.
Actual: TS2345 — Property 'warning' is missing in type '...Logger'.
If the type error is worked around with as any, running the test throws TypeError: context.logger.warning is not a function at runtime, since the mock object literal only defines debug/info/warn/error/fatal.
Environment
- Package:
jsr:@swamp-club/swamp-testing - Versions checked:
0.20260824.32,0.20260828.33(latest as of filing) - Mock source:
test_context.ts, theconst logger = { debug, info, warn, error, fatal }object (~line 278), wherewarn(message, ...args)internally doescaptureLog("warning", message, args)— so the mock's ownLogLevelunion already has"warning"as a value, it's just the method name that doesn't match. - Real-runtime doc reference: extension model API docs list logger levels as
trace, debug, info, warning, error, fatal.
Suggested Fix
Rename the mock's warn method to warning (or add warning as an alias of warn) so context.logger structurally matches the real runtime's documented Logger interface.
Shipped
Click a lifecycle step above to view its details.
stack72 commented 9/10/2026, 5:15:53 PM
Thanks @aaronge for reporting this! We shipped: Add .warning() method to the mock Logger in @swamp-club/swamp-testing so it structurally matches the real LogTape Logger used at runtime. The Logger interface in types.ts and the mock object in test_context.ts both need .warning() added as an alias that stores the level as 'warning' — matching what .warn() already does internally.. The fix has been merged and a release is on its way. We appreciate your contribution to swamp.
Sign in to post a ripple.