1
0
Fork 0

try to fix test

pull/1526/head
Tatyana Kostromskaya 2023-09-15 13:28:29 +00:00
parent b2d5fa216f
commit 8c1e6a00f0
2 changed files with 9 additions and 8 deletions

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()
})

View File

@ -1,5 +1,5 @@
import * as http from 'http'
import proxy from 'proxy'
import * as proxy from 'proxy'
import {getOctokit} from '../src/github'
import {GitHub, getOctokitOptions} from '../src/utils'
@ -12,7 +12,7 @@ describe('@actions/github', () => {
beforeAll(async () => {
// Start proxy server
proxyServer = proxy()
proxyServer = proxy.createProxy()
await new Promise(resolve => {
const port = Number(proxyUrl.split(':')[2])
proxyServer.listen(port, () => resolve(null))