aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/tests/src/shared/mock-servers/mock-proxy.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/tests/src/shared/mock-servers/mock-proxy.ts')
-rw-r--r--packages/tests/src/shared/mock-servers/mock-proxy.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/tests/src/shared/mock-servers/mock-proxy.ts b/packages/tests/src/shared/mock-servers/mock-proxy.ts
new file mode 100644
index 000000000..e731670d8
--- /dev/null
+++ b/packages/tests/src/shared/mock-servers/mock-proxy.ts
@@ -0,0 +1,24 @@
1import { createServer, Server } from 'http'
2import { createProxy } from 'proxy'
3import { getPort, terminateServer } from './shared.js'
4
5class MockProxy {
6 private server: Server
7
8 initialize () {
9 return new Promise<number>(res => {
10 this.server = createProxy(createServer())
11 this.server.listen(0, () => res(getPort(this.server)))
12 })
13 }
14
15 terminate () {
16 return terminateServer(this.server)
17 }
18}
19
20// ---------------------------------------------------------------------------
21
22export {
23 MockProxy
24}