diff options
Diffstat (limited to 'shared/extra-utils/mock-servers/mock-proxy.ts')
-rw-r--r-- | shared/extra-utils/mock-servers/mock-proxy.ts | 7 |
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 | ||
2 | import { createServer, Server } from 'http' | 2 | import { createServer, Server } from 'http' |
3 | import proxy from 'proxy' | 3 | import proxy from 'proxy' |
4 | import { randomInt } from '@shared/core-utils' | 4 | import { getPort, terminateServer } from './utils' |
5 | import { terminateServer } from './utils' | ||
6 | 5 | ||
7 | class MockProxy { | 6 | class 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 | ||