MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / waitFor

Function waitFor

packages/server/test/sessions.e2e.test.ts:158–170  ·  view source on GitHub ↗
(
  received: Record<string, unknown>[],
  pred: (f: Record<string, unknown>) => boolean,
  timeoutMs = 2000,
)

Source from the content-addressed store, hash-verified

156}
157
158async function waitFor(
159 received: Record<string, unknown>[],
160 pred: (f: Record<string, unknown>) => boolean,
161 timeoutMs = 2000,
162): Promise<Record<string, unknown>> {
163 const start = Date.now();
164 while (Date.now() - start < timeoutMs) {
165 const found = received.find(pred);
166 if (found !== undefined) return found;
167 await new Promise((resolve) => setTimeout(resolve, 10));
168 }
169 throw new Error(`timed out waiting for frame; got ${JSON.stringify(received)}`);
170}
171
172describe('POST /api/v1/sessions — create', () => {
173 it('returns a Session payload with snake_case + ISO Z timestamps', async () => {

Callers 2

openSessionListListenerFunction · 0.70

Calls 1

nowMethod · 0.65

Tested by

no test coverage detected