diff --git a/test/cookie/global-headers.js b/test/cookie/global-headers.js index e78566905a1..1dc9d9a5857 100644 --- a/test/cookie/global-headers.js +++ b/test/cookie/global-headers.js @@ -1,6 +1,6 @@ 'use strict' -const { test, skip } = require('node:test') +const { describe, test } = require('node:test') const assert = require('node:assert') const { deleteCookie, @@ -10,15 +10,8 @@ const { } = require('../..') const { getHeadersList } = require('../../lib/cookies/util') -/* global Headers */ - -if (!globalThis.Headers) { - skip('No global Headers to test') - process.exit(0) -} - -test('Using global Headers', async (t) => { - await t.test('deleteCookies', () => { +describe('Using global Headers', async () => { + test('deleteCookies', () => { const headers = new Headers() assert.equal(headers.get('set-cookie'), null) @@ -26,7 +19,7 @@ test('Using global Headers', async (t) => { assert.equal(headers.get('set-cookie'), 'undici=; Expires=Thu, 01 Jan 1970 00:00:00 GMT') }) - await t.test('getCookies', () => { + test('getCookies', () => { const headers = new Headers({ cookie: 'get=cookies; and=attributes' }) @@ -34,7 +27,7 @@ test('Using global Headers', async (t) => { assert.deepEqual(getCookies(headers), { get: 'cookies', and: 'attributes' }) }) - await t.test('getSetCookies', () => { + test('getSetCookies', () => { const headers = new Headers({ 'set-cookie': 'undici=getSetCookies; Secure' }) @@ -54,7 +47,7 @@ test('Using global Headers', async (t) => { } }) - await t.test('setCookie', () => { + test('setCookie', () => { const headers = new Headers() setCookie(headers, { name: 'undici', value: 'setCookie' }) diff --git a/test/fetch/http2.js b/test/fetch/http2.js index 0562730b26b..0793a21556c 100644 --- a/test/fetch/http2.js +++ b/test/fetch/http2.js @@ -14,8 +14,6 @@ const { Client, fetch, Headers } = require('../..') const { closeClientAndServerAsPromise } = require('../utils/node-http') -const nodeVersion = Number(process.version.split('v')[1].split('.')[0]) - test('[Fetch] Issue#2311', async (t) => { const expectedBody = 'hello from client!' @@ -180,7 +178,6 @@ test('[Fetch] Should handle h2 request with body (string or buffer)', async (t) // Skipping for now, there is something odd in the way the body is handled test( '[Fetch] Should handle h2 request with body (stream)', - { skip: nodeVersion === 16 }, async (t) => { const server = createSecureServer(pem) const expectedBody = readFileSync(__filename, 'utf-8') diff --git a/test/gc.js b/test/gc.js index 91ea6ab170c..1a0bf8bcb96 100644 --- a/test/gc.js +++ b/test/gc.js @@ -6,17 +6,13 @@ const { test, after } = require('node:test') const { createServer } = require('node:net') const { Client, Pool } = require('..') -const SKIP = ( - typeof WeakRef === 'undefined' || - typeof FinalizationRegistry === 'undefined' || - typeof global.gc === 'undefined' -) +const skip = typeof global.gc === 'undefined' setInterval(() => { global.gc() }, 100).unref() -test('gc should collect the client if, and only if, there are no active sockets', { skip: SKIP }, async t => { +test('gc should collect the client if, and only if, there are no active sockets', { skip }, async t => { t = tspl(t, { plan: 4 }) const server = createServer((socket) => { @@ -60,7 +56,7 @@ test('gc should collect the client if, and only if, there are no active sockets' await t.completed }) -test('gc should collect the pool if, and only if, there are no active sockets', { skip: SKIP }, async t => { +test('gc should collect the pool if, and only if, there are no active sockets', { skip }, async t => { t = tspl(t, { plan: 4 }) const server = createServer((socket) => { diff --git a/test/node-test/autoselectfamily.js b/test/node-test/autoselectfamily.js index 678a8959042..196f219fc79 100644 --- a/test/node-test/autoselectfamily.js +++ b/test/node-test/autoselectfamily.js @@ -1,6 +1,6 @@ 'use strict' -const { test, skip } = require('node:test') +const { test } = require('node:test') const dgram = require('node:dgram') const { Resolver } = require('node:dns') const dnsPacket = require('dns-packet') @@ -16,11 +16,7 @@ const { tspl } = require('@matteo.collina/tspl') * explicitly passed in tests in this file to avoid compatibility problems across release lines. * */ - -if (!nodeHasAutoSelectFamily) { - skip('autoSelectFamily is not supportee') - process.exit() -} +const skip = !nodeHasAutoSelectFamily function _lookup (resolver, hostname, options, cb) { resolver.resolve(hostname, 'ANY', (err, replies) => { @@ -68,7 +64,7 @@ function createDnsServer (ipv6Addr, ipv4Addr, cb) { }) } -test('with autoSelectFamily enable the request succeeds when using request', async (t) => { +test('with autoSelectFamily enable the request succeeds when using request', { skip }, async (t) => { const p = tspl(t, { plan: 3 }) createDnsServer('::1', '127.0.0.1', function (_, { dnsServer, lookup }) { @@ -108,7 +104,7 @@ test('with autoSelectFamily enable the request succeeds when using request', asy await p.completed }) -test('with autoSelectFamily enable the request succeeds when using a client', async (t) => { +test('with autoSelectFamily enable the request succeeds when using a client', { skip }, async (t) => { const p = tspl(t, { plan: 3 }) createDnsServer('::1', '127.0.0.1', function (_, { dnsServer, lookup }) { @@ -149,7 +145,7 @@ test('with autoSelectFamily enable the request succeeds when using a client', as await p.completed }) -test('with autoSelectFamily disabled the request fails when using request', async (t) => { +test('with autoSelectFamily disabled the request fails when using request', { skip }, async (t) => { const p = tspl(t, { plan: 1 }) createDnsServer('::1', '127.0.0.1', function (_, { dnsServer, lookup }) { @@ -177,7 +173,7 @@ test('with autoSelectFamily disabled the request fails when using request', asyn await p.completed }) -test('with autoSelectFamily disabled the request fails when using a client', async (t) => { +test('with autoSelectFamily disabled the request fails when using a client', { skip }, async (t) => { const p = tspl(t, { plan: 1 }) createDnsServer('::1', '127.0.0.1', function (_, { dnsServer, lookup }) { diff --git a/test/node-test/diagnostics-channel/connect-error.js b/test/node-test/diagnostics-channel/connect-error.js index ecab3856b89..38dbd9d717f 100644 --- a/test/node-test/diagnostics-channel/connect-error.js +++ b/test/node-test/diagnostics-channel/connect-error.js @@ -1,17 +1,8 @@ 'use strict' -const { test, skip } = require('node:test') +const { test } = require('node:test') const { tspl } = require('@matteo.collina/tspl') - -let diagnosticsChannel - -try { - diagnosticsChannel = require('node:diagnostics_channel') -} catch { - skip('missing diagnostics_channel') - process.exit(0) -} - +const diagnosticsChannel = require('node:diagnostics_channel') const { Client } = require('../../..') test('Diagnostics channel - connect error', (t) => { diff --git a/test/node-test/diagnostics-channel/error.js b/test/node-test/diagnostics-channel/error.js index b4861b8f71c..ce6e0978146 100644 --- a/test/node-test/diagnostics-channel/error.js +++ b/test/node-test/diagnostics-channel/error.js @@ -1,17 +1,8 @@ 'use strict' -const { test, skip, after } = require('node:test') +const { test, after } = require('node:test') const { tspl } = require('@matteo.collina/tspl') - -let diagnosticsChannel - -try { - diagnosticsChannel = require('node:diagnostics_channel') -} catch { - skip('missing diagnostics_channel') - process.exit(0) -} - +const diagnosticsChannel = require('node:diagnostics_channel') const { Client } = require('../../..') const { createServer } = require('node:http') diff --git a/test/node-test/diagnostics-channel/get.js b/test/node-test/diagnostics-channel/get.js index cde68a46f2c..3366481910b 100644 --- a/test/node-test/diagnostics-channel/get.js +++ b/test/node-test/diagnostics-channel/get.js @@ -1,17 +1,8 @@ 'use strict' -const { test, skip, after } = require('node:test') +const { test, after } = require('node:test') const { tspl } = require('@matteo.collina/tspl') - -let diagnosticsChannel - -try { - diagnosticsChannel = require('node:diagnostics_channel') -} catch { - skip('missing diagnostics_channel') - process.exit(0) -} - +const diagnosticsChannel = require('node:diagnostics_channel') const { Client } = require('../../..') const { createServer } = require('node:http') diff --git a/test/node-test/diagnostics-channel/post-stream.js b/test/node-test/diagnostics-channel/post-stream.js index a50d5ea02c0..49fa0be1a04 100644 --- a/test/node-test/diagnostics-channel/post-stream.js +++ b/test/node-test/diagnostics-channel/post-stream.js @@ -1,18 +1,9 @@ 'use strict' -const { test, skip, after } = require('node:test') +const { test, after } = require('node:test') const { tspl } = require('@matteo.collina/tspl') const { Readable } = require('node:stream') - -let diagnosticsChannel - -try { - diagnosticsChannel = require('node:diagnostics_channel') -} catch { - skip('missing diagnostics_channel') - process.exit(0) -} - +const diagnosticsChannel = require('node:diagnostics_channel') const { Client } = require('../../..') const { createServer } = require('node:http') diff --git a/test/node-test/diagnostics-channel/post.js b/test/node-test/diagnostics-channel/post.js index 45368e3fdab..cddb22ace17 100644 --- a/test/node-test/diagnostics-channel/post.js +++ b/test/node-test/diagnostics-channel/post.js @@ -1,17 +1,8 @@ 'use strict' -const { test, skip, after } = require('node:test') +const { test, after } = require('node:test') const { tspl } = require('@matteo.collina/tspl') - -let diagnosticsChannel - -try { - diagnosticsChannel = require('node:diagnostics_channel') -} catch { - skip('missing diagnostics_channel') - process.exit(0) -} - +const diagnosticsChannel = require('node:diagnostics_channel') const { Client } = require('../../../') const { createServer } = require('node:http')