Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
TypeScript
mods: tests settle a started dispatch with clock.settle()
poteatbf4322ffe250
diff --git a/mods/README.md b/mods/README.mdindex ceb3f659..34ccd54c 100644--- a/mods/README.md+++ b/mods/README.md@@ -72,8 +72,10 @@ each member a plain function over `on` registering hooks where the test callsit: `mock.env(on, variables)` for `$.env`, `mock.store(on, entries)` for`$.store`, and `mock.clock(on)` for `$.clock`, whose `advance(ms)` resolvesevery wait the mod asked for (`$.clock.sleep`, `after`, `every`) as the clock-crosses it. `$.ui.press({ plugin, key })` presses a `Button` the test-rendered, as a click in the terminal does.+crosses it. To see what a dispatch does before it answers, start it+unawaited, `await clock.settle()`, then look: the clock stays where it was.+`$.ui.press({ plugin, key })` presses a `Button` the test rendered, as a+click in the terminal does.`tsc -p mods/tsconfig.json` typechecks every mod's hooks and tests against`types/` and each mod's own `types/` contract.diff --git a/mods/diff/tests/register.test.ts b/mods/diff/tests/register.test.tsindex e354c9c5..13057d2c 100644--- a/mods/diff/tests/register.test.ts+++ b/mods/diff/tests/register.test.ts@@ -24,11 +24,11 @@ describe('register', () => {const booting = $.session.start(Fixtures.SESSION)- await clock.advance(0)+ await clock.settle()const ran = $.command.run(Fixtures.DIFF)- await clock.advance(0)+ await clock.settle()expect(probes, 'the boot probe, which /diff joined').toHaveLength(1)@@ -148,7 +148,7 @@ describe('register', () => {element: 'close',})- await world.clock.advance(0)+ await world.clock.settle()expect(world.closed.map(pane => pane.id)).toEqual(['diff'])expect(await $.command.run(Fixtures.DIFF)).toEqual({})diff --git a/mods/types/claude-code.d.ts b/mods/types/claude-code.d.tsindex 9166cd5e..fb731c0e 100644--- a/mods/types/claude-code.d.ts+++ b/mods/types/claude-code.d.ts@@ -8943,6 +8943,16 @@ declare module 'claude-code/testing' {* @returns resolves once the clock is there and the event loop settled*/set: (ms: number) => Promise<void>;+ /**+ * Lets what is already under way run as far as it can without the clock+ * moving: every wait due now resolves and the event loop settles.+ *+ * The same as `advance(0)`; the name for the step between starting a+ * dispatch unawaited and looking at what it did.+ *+ * @returns resolves once the event loop settled, the time where it was+ */+ settle: () => Promise<void>;/*** Resolves once the clock has moved this far past now: how a hook of the* test's answers late.