Skip to content

Commit 8390c7c

Browse files
committed
refactor: use getAvailablePort in proxy.test.ts
1 parent 917d008 commit 8390c7c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/unit/proxy.test.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { HttpCode } from "../../src/common/http"
66
import { proxy } from "../../src/node/proxy"
77
import * as httpserver from "../utils/httpserver"
88
import * as integration from "../utils/integration"
9+
import { getAvailablePort } from "../utils/helpers"
910

1011
describe("proxy", () => {
1112
const nhooyrDevServer = new httpserver.HttpServer()
@@ -166,14 +167,16 @@ describe("proxy", () => {
166167
// src/node/proxy.ts, you should probably add it to
167168
// this test suite.
168169
describe("proxy (standalone)", () => {
169-
const PORT = 9003
170-
const PROXY_PORT = 8003
171-
const URL = `http://localhost:${PORT}`
172-
const PROXY_URL = `http://localhost:${PROXY_PORT}`
170+
let URL = ""
171+
let PROXY_URL = ""
173172
let testServer: http.Server
174173
let proxyTarget: http.Server
175174

176175
beforeEach(async () => {
176+
const PORT = await getAvailablePort()
177+
const PROXY_PORT = await getAvailablePort()
178+
URL = `http://localhost:${PORT}`
179+
PROXY_URL = `http://localhost:${PROXY_PORT}`
177180
// Define server and a proxy server
178181
testServer = http.createServer((req, res) => {
179182
proxy.web(req, res, {

0 commit comments

Comments
 (0)