test(browser): avoid duplicating source-map listener setup

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
Rudy Celekli 2026-10-09 12:12:08 -04:00 committed by morluto
parent 82bbe74333
commit 9367dc13bd
1 changed files with 4 additions and 4 deletions

View File

@ -1,3 +1,4 @@
import { once } from "node:events";
import { createServer } from "node:http";
import { expect, it } from "vitest";
@ -26,10 +27,9 @@ it("follows only HTTP redirect statuses when a source-map response carries Locat
.end();
});
try {
await new Promise<void>((resolve, reject) => {
server.once("error", reject);
server.listen(0, "127.0.0.1", resolve);
});
const listening = once(server, "listening");
server.listen(0, "127.0.0.1");
await listening;
const address = server.address();
if (address === null || typeof address === "string")
throw new TypeError("Expected TCP listener");