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

#371 createModelTestContext: storedResources not used by readResource; readResource always returns null

Opened by leeehinman · 5/18/2026· Shipped 5/18/2026

Description

createModelTestContext accepts a storedResources option documented as "Pre-seed data for readResource calls", but context.readResource() always returns null regardless of what is seeded. Additionally, readResource also returns null after a writeResource call within the same test context.

Steps to Reproduce

import { createModelTestContext } from "jsr:@systeminit/swamp-testing";

Deno.test("storedResources should work", async () => {
  const { context } = createModelTestContext({
    globalArgs: { name: "foo" },
    storedResources: { "foo": { val: 42 } },
  });
  const r = await context.readResource("item", "foo");
  console.log(r); // prints: null  (expected: { val: 42 })
});

Also reproducible with write-then-read:

await context.writeResource("item", "foo", { val: 99 });
const r = await context.readResource("item", "foo");
console.log(r); // prints: null  (expected: { val: 99 })

Expected Behavior

  • readResource should return the seeded storedResources value when the instance name matches.
  • readResource should return data written by writeResource in the same test context.

Impact

Extensions that call readResource in update/sync/delete methods cannot be unit-tested using createModelTestContext. The workaround is to inject state via method arguments.

Environment

  • swamp version: 20260516.045246.0-sha.e6eda98d
  • jsr:@systeminit/swamp-testing (version resolved at test time)
02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 1 MOREASSIGNED+ 2 MOREREVIEW+ 3 MOREPR_MERGEDCOMPLETE

Shipped

5/18/2026, 7:31:56 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack725/18/2026, 6:32:38 PM

Sign in to post a ripple.