fix tests
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import * as http from 'http'
|
||||
import * as https from 'https'
|
||||
import * as proxy from 'proxy'
|
||||
import { createProxy } 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'
|
||||
const originalProxyUrl = process.env['https_proxy']
|
||||
process.env['https_proxy'] = proxyUrl
|
||||
// eslint-disable-next-line import/first
|
||||
import {getOctokit} from '../src/github'
|
||||
import { getOctokit } from '../src/github'
|
||||
|
||||
describe('@actions/github', () => {
|
||||
let proxyConnects: string[]
|
||||
@@ -16,7 +16,7 @@ describe('@actions/github', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// Start proxy server
|
||||
proxyServer = proxy.createProxy()
|
||||
proxyServer = createProxy()
|
||||
await new Promise<void>(resolve => {
|
||||
const port = Number(proxyUrl.split(':')[2])
|
||||
proxyServer.listen(port, () => resolve())
|
||||
@@ -70,7 +70,7 @@ describe('@actions/github', () => {
|
||||
const repository = await octokit.graphql(
|
||||
'{repository(owner:"actions", name:"toolkit"){name}}'
|
||||
)
|
||||
expect(repository).toEqual({repository: {name: 'toolkit'}})
|
||||
expect(repository).toEqual({ repository: { name: 'toolkit' } })
|
||||
expect(proxyConnects).toEqual(['api.github.com:443'])
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user