Skip to content

Commit 683720a

Browse files
test: fix flaky test
1 parent a529eb0 commit 683720a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

test/index.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ describe("@socket.io/cluster-adapter", () => {
3737
PORT,
3838
});
3939

40-
const clientSocket = ioc(`http://localhost:${PORT}`);
41-
clientSocket.on("connect", async () => {
42-
workers.push(worker);
43-
clientSockets.push(clientSocket);
44-
if (clientSockets.length === NODES_COUNT) {
45-
await sleep(100);
46-
47-
done();
48-
}
40+
worker.on("listening", () => {
41+
const clientSocket = ioc(`http://localhost:${PORT}`);
42+
43+
clientSocket.on("connect", async () => {
44+
workers.push(worker);
45+
clientSockets.push(clientSocket);
46+
if (clientSockets.length === NODES_COUNT) {
47+
done();
48+
}
49+
});
4950
});
5051
}
5152
});

0 commit comments

Comments
 (0)