Skip to content

Commit

Permalink
Use promisified timeouts (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing authored Oct 21, 2024
1 parent 336783f commit b012060
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions test/integration/live-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createWriteStream } from 'fs'
import { IncomingMessage, RequestListener } from 'http'
import { join } from 'path'
import { pipeline } from 'stream/promises'
import { setTimeout } from 'timers/promises'
import got, { RequiredRetryOptions } from 'got'
import intoStream = require('into-stream')
import debug = require('debug')
Expand Down Expand Up @@ -637,7 +638,7 @@ describe('API integration', { timeout: 60000 }, () => {
const newUrl = `${server.url}${newPath}`

// I think there are some eventual consistency issues here
await new Promise((resolve) => setTimeout(resolve, 1000))
await setTimeout(1000)

const result = await client.getAssembly(assemblyId)

Expand All @@ -652,7 +653,7 @@ describe('API integration', { timeout: 60000 }, () => {

try {
// If we quit immediately, things will not get cleaned up and jest will hang
await new Promise((resolve) => setTimeout(resolve, 2000))
await setTimeout(2000)
resolve()
} catch (err) {
reject(err)
Expand All @@ -667,7 +668,7 @@ describe('API integration', { timeout: 60000 }, () => {
expect(path).toBe('/')
expect(result.notify_url).toBe(server.url)

await new Promise((resolve) => setTimeout(resolve, 2000))
await setTimeout(2000)
await client.replayAssemblyNotification(assemblyId, { notify_url: newUrl })
} catch (err) {
reject(err)
Expand Down
4 changes: 2 additions & 2 deletions test/testserver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createServer, RequestListener, Server } from 'http'
import { setTimeout } from 'timers/promises'
import got from 'got'
import debug from 'debug'

Expand Down Expand Up @@ -93,8 +94,7 @@ export async function createTestServer(onRequest: RequestListener) {
return
} catch (err) {
// console.error(err.message)
// eslint-disable-next-line no-shadow
await new Promise((resolve) => setTimeout(resolve, 3000))
await setTimeout(3000)
}
}
throw new Error('Timed out checking for an operational tunnel')
Expand Down
2 changes: 1 addition & 1 deletion test/tunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function createTunnel({
return url
} catch (err) {
log('dns err', (err as Error).message)
await new Promise((resolve) => setTimeout(resolve, 3000))
await timers.setTimeout(3000)
}
}

Expand Down

0 comments on commit b012060

Please sign in to comment.