aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/mock-servers/mock-proxy.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/mock-servers/mock-proxy.ts')
-rw-r--r--shared/extra-utils/mock-servers/mock-proxy.ts7
1 files changed, 2 insertions, 5 deletions
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 @@
1 1
2import { createServer, Server } from 'http' 2import { createServer, Server } from 'http'
3import proxy from 'proxy' 3import proxy from 'proxy'
4import { randomInt } from '@shared/core-utils' 4import { getPort, terminateServer } from './utils'
5import { terminateServer } from './utils'
6 5
7class MockProxy { 6class MockProxy {
8 private server: Server 7 private server: Server
9 8
10 initialize () { 9 initialize () {
11 return new Promise<number>(res => { 10 return new Promise<number>(res => {
12 const port = 46000 + randomInt(1, 1000)
13
14 this.server = proxy(createServer()) 11 this.server = proxy(createServer())
15 this.server.listen(port, () => res(port)) 12 this.server.listen(0, () => res(getPort(this.server)))
16 }) 13 })
17 } 14 }
18 15