Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix failing tests #2097

Merged
merged 9 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"lint:fix": "standard --fix | snazzy",
"test": "npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:wpt && npm run test:websocket && npm run test:jest && npm run test:typescript",
"test:cookies": "node scripts/verifyVersion 16 || tap test/cookie/*.js",
"test:node-fetch": "node scripts/verifyVersion.js 16 || mocha test/node-fetch",
"test:node-fetch": "node scripts/verifyVersion.js 16 || mocha --exit test/node-fetch",
"test:fetch": "node scripts/verifyVersion.js 16 || (npm run build:node && tap --expose-gc test/fetch/*.js && tap test/webidl/*.js)",
"test:jest": "node scripts/verifyVersion.js 14 || jest",
"test:tap": "tap test/*.js test/diagnostics-channel/*.js",
Expand Down
4 changes: 3 additions & 1 deletion test/agent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { test } = require('tap')
const { test, teardown } = require('tap')
const http = require('http')
const { PassThrough } = require('stream')
const { kRunning } = require('../lib/core/symbols')
Expand Down Expand Up @@ -705,3 +705,5 @@ test('the dispatcher is truly global', t => {
t.equal(agent, undiciFresh.getGlobalDispatcher())
t.end()
})

teardown(() => process.exit())
6 changes: 3 additions & 3 deletions test/connect-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ const sleep = require('atomic-sleep')
test('priotorise socket errors over timeouts', (t) => {
t.plan(1)
const connectTimeout = 1000
const client = new Pool('http:https://foobar.bar:1234', { connectTimeout })
const client = new Pool('http:https://foobar.bar:1234', { connectTimeout: 1 })

client.request({ method: 'GET', path: '/foobar' })
.then(() => t.fail())
.catch((err) => {
t.equal(err.code, 'ENOTFOUND')
})

// block for 2s which is enough for the dns lookup to complete and TO to fire
sleep(connectTimeout * 2)
// block for 1s which is enough for the dns lookup to complete and TO to fire
sleep(connectTimeout)
})

// never connect
Expand Down
4 changes: 3 additions & 1 deletion test/fetch/client-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict'

const { test } = require('tap')
const { test, teardown } = require('tap')
const { createServer } = require('http')
const { ReadableStream } = require('stream/web')
const { Blob } = require('buffer')
Expand Down Expand Up @@ -672,3 +672,5 @@ test('Receiving non-Latin1 headers', async (t) => {
t.same(lengths, [30, 34, 94, 104, 90])
t.end()
})

teardown(() => process.exit())
12 changes: 8 additions & 4 deletions test/fetch/jsdom-abortcontroller-1910-1464495619.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ const { JSDOM } = require('jsdom')
test('third party AbortControllers', async (t) => {
const server = createServer((_, res) => res.end()).listen(0)

t.teardown(server.close.bind(server))
await once(server, 'listening')

const { AbortController } = new JSDOM().window
const controller = new AbortController()
let controller = new AbortController()

t.teardown(() => {
controller.abort()
controller = null
return server.close()
})
await once(server, 'listening')

await t.resolves(fetch(`http:https://localhost:${server.address().port}`, {
signal: controller.signal
Expand Down
11 changes: 6 additions & 5 deletions test/fetch/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

'use strict'

const { test } = require('tap')
const { test, teardown } = require('tap')
const {
Request,
Headers,
fetch
} = require('../../')
const { kState } = require('../../lib/fetch/symbols.js')
const {
Blob: ThirdPartyBlob,
FormData: ThirdPartyFormData
Expand Down Expand Up @@ -199,7 +198,7 @@ test('undefined window', t => {

test('undefined body', t => {
const req = new Request('http:https://asd', { body: undefined })
t.equal(req[kState].body, null)
t.equal(req.body, null)
t.end()
})

Expand Down Expand Up @@ -298,7 +297,7 @@ test('post aborted signal', t => {
} else {
t.pass()
}
})
}, { once: true })
ac.abort('gwak')
})

Expand Down Expand Up @@ -346,7 +345,7 @@ test('post aborted signal cloned', t => {
} else {
t.pass()
}
})
}, { once: true })
ac.abort('gwak')
})

Expand Down Expand Up @@ -476,3 +475,5 @@ test('set-cookie headers get cleared when passing a Request as first param', (t)
t.same(req2.headers.getSetCookie(), [])
t.end()
})

teardown(() => process.exit())
4 changes: 3 additions & 1 deletion test/proxy-agent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { test } = require('tap')
const { test, teardown } = require('tap')
const { request, fetch, setGlobalDispatcher, getGlobalDispatcher } = require('..')
const { InvalidArgumentError } = require('../lib/core/errors')
const { nodeMajor } = require('../lib/core/util')
Expand Down Expand Up @@ -692,3 +692,5 @@ function buildSSLProxy () {
server.listen(0, () => resolve(server))
})
}

teardown(() => process.exit())
Loading