Path: blob/master/src/packages/backend/get-port.test.ts
1447 views
import getPort, { getPorts } from "./get-port";12describe("test getting a random available port", () => {3it("tests it", async () => {4const port = await getPort();5expect(port).toBeGreaterThan(1024);6});7});89describe("test getPorts -- getting many ports at once in parallel", () => {10const count = 1000;11it(`get ${count} ports at once, thus testing it isn't too slow and also nice to see no conflicts`, async () => {12const start = Date.now();13const w = await getPorts(count);14expect(new Set(w).size).toBe(count);15// takes ~200ms to get 5000 of them on my laptop, but with heavy load16// it can be much slower.17expect(Date.now() - start).toBeLessThan(4000);18});19});202122