try to fix test

This commit is contained in:
Tatyana Kostromskaya committed 2023-09-15 13:28:29 +00:00
1 parent 13e3c0f169
commit 4574e1f21a
2 files changed
+9 -8

No files matched your search

+7 -6
View File
@@ -1,6 +1,6 @@
import * as http from 'http'
import * as https from 'https'
import proxy from 'proxy'
import * as proxy from 'proxy'
// Default values are set when the module is imported, so we need to set proxy first.
const proxyUrl = 'http://127.0.0.1:8081'
@@ -16,12 +16,13 @@ describe('@actions/github', () => {
beforeAll(async () => {
// Start proxy server
proxyServer = proxy()
await new Promise(resolve => {
proxyServer = proxy.createProxy()
await new Promise<void>(resolve => {
const port = Number(proxyUrl.split(':')[2])
proxyServer.listen(port, () => resolve(null))
proxyServer.listen(port, () => resolve())
})
proxyServer.on('connect', req => {
console.log('connect', req.url)
proxyConnects.push(req.url ?? '')
})
})
@@ -32,8 +33,8 @@ describe('@actions/github', () => {
afterAll(async () => {
// Stop proxy server
await new Promise(resolve => {
proxyServer.once('close', () => resolve(null))
await new Promise<void>(resolve => {
proxyServer.once('close', () => resolve())
proxyServer.close()
})