Test a mod changedplugins/mods/test
Upstream edited this page at 12 Nov 2026 04:15 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 12 Nov 2026 04:37 UTC.
Upstream edited
Recorded here
Lines+12added
Lines−1removed
From line
190
where the diff opens
First seen
1 Oct 2026
this site's first read of the page
Recorded edits10to this page, all time
### Check a result with `expect`
The whole hunk
from line 190, old and new numbered
/
from line 190
190190| `session.receive` | `($, e) => ({ text: e.text })`. Fire it with `$.session.receive({ origin: { kind: 'peer-send-message' }, text })`. |
191191| `ui.render` | `() => ({ type: 'Text', props: {}, children: ['...'] })` |
192192
193`expect` has the assertions `toBe`, `toEqual`, `toMatch`, `toMatchObject`, `toContain`, `toBeDefined`, `toBeUndefined`, and `toThrow`, and `.not` before any of them.
193### Check a result with `expect`
194
195The kit has these assertions, and the one you pick goes after the value you're checking, as in `expect(answer.text).toBe('ok')`:
196
197* **Equality**: `toBe` for the same value or object, `toEqual` for structure, `toStrictEqual` for structure plus `undefined` fields and the prototype, and `toMatchObject` for the fields you name
198* **Text**: `toMatch`, which takes a regular expression or a substring, `toStartWith`, and `toEndWith`
199* **Numbers**: `toBeGreaterThan`, `toBeGreaterThanOrEqual`, `toBeLessThan`, `toBeLessThanOrEqual`
200* **Contents**: `toContain` for a substring or a member, `toContainEqual` for a member compared by structure, `toHaveLength`, and `toHaveProperty`
201* **Presence and type**: `toBeDefined`, `toBeUndefined`, `toBeNull`, `toBeTruthy`, `toBeFalsy`, `toBeNaN`, `toBeInstanceOf`
202* **Throwing**: `toThrow`, for a function `expect` calls, or for a promise you check with `.rejects`
203
204Put `.not` in front of an assertion to check the opposite, and `.resolves` or `.rejects` to check what a promise settles with.
194205
195206When 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`.
196207
No line in this hunk matches that.