Skip to content

Commit cd8eb07

Browse files
committed
perf(test): replace subagent lifecycle polling helper
1 parent c68d107 commit cd8eb07

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/agents/openclaw-tools.subagents.sessions-spawn.lifecycle.e2e.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { beforeEach, describe, expect, it, vi } from "vitest";
22
import { emitAgentEvent } from "../infra/agent-events.js";
33
import "./test-helpers/fast-core-tools.js";
4-
import { sleep } from "../utils.js";
54
import {
65
getCallGatewayMock,
76
resetSessionsSpawnConfigOverride,
@@ -126,13 +125,12 @@ function setupSessionsSpawnGatewayMock(opts: {
126125
}
127126

128127
const waitFor = async (predicate: () => boolean, timeoutMs = 2000) => {
129-
const start = Date.now();
130-
while (!predicate()) {
131-
if (Date.now() - start > timeoutMs) {
132-
throw new Error(`timed out waiting for condition (timeoutMs=${timeoutMs})`);
133-
}
134-
await sleep(10);
135-
}
128+
await vi.waitFor(
129+
() => {
130+
expect(predicate()).toBe(true);
131+
},
132+
{ timeout: timeoutMs, interval: 10 },
133+
);
136134
};
137135

138136
function expectSingleCompletionSend(

0 commit comments

Comments
 (0)