Follow Discord
Sweep 24 Nov 2026 · 22:58Z Build v2.1.332 549 read Stable v2.1.325 Latest v2.1.331 Next v2.1.332 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · claude-code

Test a mod changedplugins/mods/test

Nearest release: v2.1.332, published 2 hours before 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 25 Nov 2026 00:57 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 25 Nov 2026 01:07 UTC.

Upstream edited
Recorded here
Lines+3added
Lines−2removed
From line 159 where the diff opens
First seen 1 Oct 2026 this site's first read of the page
Recorded edits15to this page, all time

The whole hunk

from line 159, old and new numbered
/
lines
from line 159
159159 
160160### Look up what a stub returns
161161 
162Every mods API call your mod makes in a test needs a stub that answers in Claude Code's place, except the few the kit answers itself: [`$.ui.invalidate`](https://code.claude.com/docs/en/plugins/mods/interface#redraw-when-something-changes), [`$.state`](https://code.claude.com/docs/en/plugins/mods/interface#keep-state), and `$.session.append` calls. For `$.clock` calls, use `mock.clock(on)`, or your mod's `$.clock.now()` fails with `no implementation for clock.now`.
162[`$.ui.invalidate`](https://code.claude.com/docs/en/plugins/mods/interface#redraw-when-something-changes), [`$.state`](https://code.claude.com/docs/en/plugins/mods/interface#keep-state), and `$.session.append` calls need no stub. For `$.clock` calls, use `mock.clock(on)`, or your mod's `$.clock.now()` fails with `no implementation for clock.now`. A passing test [can hide](#follow-the-test-kit’s-rules) a `no implementation for` error, and each call that fails with it needs a stub.
163163 
164164This table lists the ones mods use most. The first column is the call your mod makes or the event it passes on with `next(e)`. The second is the function to pass to `on` under that name, so the `$.store.get` row becomes `on('store.get', ($, e) => ({ value: saved.get(e.key) }))`. A `'...'` in a stub marks text for you to fill in:
165165 
from line 172
172172| `$.ui.ask` | A `tool.call` stub, because the question reaches it as a call to the `AskUserQuestion` tool: `($, e) => ({ result: { answers: { [e.questions[0].question]: 'Run it' } } })`. Check `e.tool` first if your mod passes on other tool calls. |
173173| `$.model.complete` | `() => ({ value: { isAnswered: true, text: '...', usage } })` |
174174| `$.process.run` | `($, e) => ({ value: { exitCode: 0, stdout: '...', stderr: '' } })`. `e.argv` is the argument list and `e.init` holds `cwd` and `timeoutMs`. |
175| Any mods API call that should fail | `() => ({ deny: 'the reason' })`, which makes the call reject in your mod. A stub that throws is skipped instead. |
175| To fail a call whose stub returns `{ value }` | `() => ({ deny: 'the reason' })`, which makes the call reject in your mod. `ui.toast`, `ui.log`, and `ui.status` don't reject. A stub that throws is skipped. |
176176| `session.start` | `() => ({ cwd: '/work' })` |
177177| `turn.start` | `($, e) => ({ turnId: e.turnId })` |
178178| `tool.call` | `() => ({ result: '...' })` |
from line 312
312312| `select({ key: 'size', value: 'large' })` | Picks the option with that value in the `Select` with that key |
313313| `keepsBeneath()` | In a test with no `ui.render` stub, it resolves to `true` when the drawing includes what `next(e)` returned, and `false` when your hook left it out. In a test that registers one, use `find` to look for what the stub drew. Requires Claude Code v2.1.321 or later. |
314314| `find({ key: 'more' })` or `find({ type: 'Text', text: 'Count: 2' })` | Returns the first matching element as `{ type, props, children }`, or `undefined`. `text` can be a string or a regular expression. |
315| `drawn()` | Returns the whole tree as last drawn |
315316| `unmount()` | Removes the drawing |
316317 
317318Each method resolves after your handler has finished, so you can check the result on the next line. Set `props` to what Claude Code would pass for that site. The [render sites table](https://code.claude.com/docs/en/plugins/mods/reference.md#render-sites) lists each site's props, and [the types for your build](https://code.claude.com/docs/en/plugins/mods/create.md#get-the-types-for-your-build) have their types.
Feedback