From d1bfbdeb203b0e4f37e9468861c690171156ee29 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 22 Oct 2021 14:31:38 +0200 Subject: Random listen for mocked servers --- shared/extra-utils/mock-servers/mock-proxy.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'shared/extra-utils/mock-servers/mock-proxy.ts') diff --git a/shared/extra-utils/mock-servers/mock-proxy.ts b/shared/extra-utils/mock-servers/mock-proxy.ts index 8583250f3..75ac79055 100644 --- a/shared/extra-utils/mock-servers/mock-proxy.ts +++ b/shared/extra-utils/mock-servers/mock-proxy.ts @@ -1,18 +1,15 @@ import { createServer, Server } from 'http' import proxy from 'proxy' -import { randomInt } from '@shared/core-utils' -import { terminateServer } from './utils' +import { getPort, terminateServer } from './utils' class MockProxy { private server: Server initialize () { return new Promise(res => { - const port = 46000 + randomInt(1, 1000) - this.server = proxy(createServer()) - this.server.listen(port, () => res(port)) + this.server.listen(0, () => res(getPort(this.server))) }) } -- cgit v1.2.3