test(browser): avoid duplicating source-map listener setup
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { once } from "node:events";
|
||||||
import { createServer } from "node:http";
|
import { createServer } from "node:http";
|
||||||
|
|
||||||
import { expect, it } from "vitest";
|
import { expect, it } from "vitest";
|
||||||
@@ -26,10 +27,9 @@ it("follows only HTTP redirect statuses when a source-map response carries Locat
|
|||||||
.end();
|
.end();
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await new Promise<void>((resolve, reject) => {
|
const listening = once(server, "listening");
|
||||||
server.once("error", reject);
|
server.listen(0, "127.0.0.1");
|
||||||
server.listen(0, "127.0.0.1", resolve);
|
await listening;
|
||||||
});
|
|
||||||
const address = server.address();
|
const address = server.address();
|
||||||
if (address === null || typeof address === "string")
|
if (address === null || typeof address === "string")
|
||||||
throw new TypeError("Expected TCP listener");
|
throw new TypeError("Expected TCP listener");
|
||||||
|
|||||||
Reference in New Issue
Block a user