Test a mod changedplugins/mods/test
Nearest release: v2.1.294, published 4 hours after upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 7 Oct 2026 23:23 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 7 Oct 2026 23:37 UTC.
Upstream edited
Recorded here
Lines+3added
Lines−1removed
From line
99
where the diff opens
First seen
1 Oct 2026
this site's first read of the page
Recorded edits4to this page, all time
The whole hunk
from line 99, old and new numbered
/
from line 99
9999
100100A stub for a mods API call returns an object with a `value` field, which holds what the call resolves to in your mod: `{ value: 7 }` makes `$.store.get` resolve to `7`. A stub for one of Claude Code's events, such as [`turn.step`](/docs/en/plugins/mods/reference#turns) or `tool.call`, returns that event's own result, such as `{ result: 'ok' }`. `$.session.send` and `$.prompt.fill` take their event's result too, as the table shows. [Look up what a stub returns](#look-up-what-a-stub-returns) shows which form each common name takes. These errors mean a stub is wrong or missing. A failed test's output includes a block headed `the engine reported:`, and each error appears there:
101101
102* `returned neither { value } nor { deny }`: a stub for a mods API call returned a bare value
102* `returned neither { value } nor { deny }`: a stub for a mods API call returned a bare value, which fails the test
103103* `no implementation for` followed by a name: your mod made that call and no stub answers it
104104
105105The kit also exports in-memory mocks that answer a whole namespace for you. `mock.clock(on)` answers [`$.clock`](/docs/en/plugins/mods/api#run-work-in-the-background), `mock.store(on, { count: 7 })` answers `$.store` from a store that starts with those entries, and `mock.env(on, { CI: 'true' })` answers `$.env.get` from those variables. `mock.clock` returns a mock clock that your test advances, so a test of a timer doesn't wait. `mock.store` returns nothing, so to check what your mod saved, write the two `store` stubs yourself as the [drawing test](#test-a-drawing) does.
from line 185
185185| `ui.render` | `() => ({ type: 'Text', props: {}, children: ['...'] })` |
186186
187187`expect` has the assertions `toBe`, `toEqual`, `toMatch`, `toMatchObject`, `toContain`, `toBeDefined`, `toBeUndefined`, and `toThrow`, and `.not` before any of them.
188
189When an `expect` fails inside a stub or hook that you passed to `on` as a plain function rather than an async generator, the test fails. The engine skips that hook, and the failure output names it, such as `in the test's store.set hook`.
188190
189191## Test a timer
190192
No line in this hunk matches that.