Skip to main content
← Back to list
01Issue
BugShippedSwamp CLIPublicTeam
Assigneesstack72

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

  1. In an extension model, declare a method whose execute context type requires logger.warning(message, properties?) (matching documented real-runtime usage).
  2. Call context.logger.warning("some message", { foo: "bar" }) inside execute.
  3. Write a _test.ts that imports the model and calls model.methods.<method>.execute({}, context) where context comes from createModelTestContext().
  4. Run deno check on the test file.

Expected: type-checks cleanly, since the mock context should satisfy the same interface the real runtime does. Actual: TS2345Property '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, the const logger = { debug, info, warn, error, fatal } object (~line 278), where warn(message, ...args) internally does captureLog("warning", message, args) — so the mock's own LogLevel union 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.

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 1 MOREASSIGNED+ 2 MOREREVIEW+ 7 MOREPR_MERGED+ 2 MORESESSION_SUMMARIZED

Shipped

9/10/2026, 5:15:46 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack729/10/2026, 2:54:09 PM
Editable. Press Enter to edit.

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.