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

Function waitForCount

packages/server/test/ws-handshake.e2e.test.ts:270–283  ·  view source on GitHub ↗
(
  counts: readonly number[],
  target: number,
  timeoutMs: number,
)

Source from the content-addressed store, hash-verified

268});
269
270async function waitForCount(
271 counts: readonly number[],
272 target: number,
273 timeoutMs: number,
274): Promise<void> {
275 const deadline = Date.now() + timeoutMs;
276 while (Date.now() < deadline) {
277 if (counts.includes(target)) return;
278 await new Promise((res) => {
279 setTimeout(res, 10);
280 });
281 }
282 throw new Error(`count ${String(target)} not observed; got ${JSON.stringify(counts)}`);
283}
284
285describe('WS gateway connection-count observer', () => {
286 it('reports size 1 after a connect and size 0 after the last disconnect', async () => {

Callers 1

Calls 1

nowMethod · 0.65

Tested by

no test coverage detected