mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 09:47:40 +00:00
perf(test): replace manual log polling with vi.waitFor
This commit is contained in:
@@ -117,16 +117,13 @@ describe("web monitor inbox", () => {
|
|||||||
sock.ev.emit("messages.upsert", upsert);
|
sock.ev.emit("messages.upsert", upsert);
|
||||||
await new Promise((resolve) => setImmediate(resolve));
|
await new Promise((resolve) => setImmediate(resolve));
|
||||||
|
|
||||||
const content = await (async () => {
|
await vi.waitFor(
|
||||||
const deadline = Date.now() + 2_000;
|
() => {
|
||||||
while (Date.now() < deadline) {
|
expect(fsSync.existsSync(logPath)).toBe(true);
|
||||||
if (fsSync.existsSync(logPath)) {
|
},
|
||||||
return fsSync.readFileSync(logPath, "utf-8");
|
{ timeout: 2_000, interval: 5 },
|
||||||
}
|
);
|
||||||
await new Promise((resolve) => setTimeout(resolve, 25));
|
const content = fsSync.readFileSync(logPath, "utf-8");
|
||||||
}
|
|
||||||
throw new Error(`expected log file to exist: ${logPath}`);
|
|
||||||
})();
|
|
||||||
expect(content).toMatch(/web-inbound/);
|
expect(content).toMatch(/web-inbound/);
|
||||||
expect(content).toMatch(/ping/);
|
expect(content).toMatch(/ping/);
|
||||||
await listener.close();
|
await listener.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user