diff --git a/package.json b/package.json index 12c47f46824..dfb2dea12be 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "main": "index.js", "types": "index.d.ts", "scripts": { - "build:node": "npx esbuild@0.19.10 index-fetch.js --bundle --platform=node --outfile=undici-fetch.js --define:esbuildDetection=1 --keep-names && node scripts/strip-comments.js", + "build:node": "esbuild index-fetch.js --bundle --platform=node --outfile=undici-fetch.js --define:esbuildDetection=1 --keep-names && node scripts/strip-comments.js", "prebuild:wasm": "node build/wasm.js --prebuild", "build:wasm": "node build/wasm.js --docker", "generate-pem": "node scripts/generate-pem.js", @@ -111,6 +111,7 @@ "c8": "^10.0.0", "cross-env": "^7.0.3", "dns-packet": "^5.4.0", + "esbuild": "^0.19.10", "eslint": "^9.9.0", "fast-check": "^3.17.1", "https-pem": "^3.0.0", diff --git a/test/issue-1670.js b/test/issue-1670.js deleted file mode 100644 index 26904d4da8f..00000000000 --- a/test/issue-1670.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict' - -const { test } = require('node:test') -const { request } = require('..') - -test('https://github.com/mcollina/undici/issues/1670', async () => { - const { body } = await request('https://api.github.com/user/emails') - - await body.text() -}) diff --git a/test/node-fetch/main.js b/test/node-fetch/main.js index 4b584281ab6..1473caf198c 100644 --- a/test/node-fetch/main.js +++ b/test/node-fetch/main.js @@ -23,6 +23,8 @@ const HeadersOrig = require('../../lib/web/fetch/headers.js').Headers const ResponseOrig = require('../../lib/web/fetch/response.js').Response const RequestOrig = require('../../lib/web/fetch/request.js').Request const TestServer = require('./utils/server.js') +const { createServer } = require('node:http') +const { default: tspl } = require('@matteo.collina/tspl') const { Uint8Array: VMUint8Array @@ -1617,15 +1619,23 @@ describe('node-fetch', () => { }) }) - it('should support http request', { timeout: 5000 }, function () { - const url = 'https://github.com/' - const options = { - method: 'HEAD' - } - return fetch(url, options).then(res => { - assert.strictEqual(res.status, 200) - assert.strictEqual(res.ok, true) + it('should support http request', { timeout: 5000 }, async function (t) { + t = tspl(t, { plan: 2 }) + const server = createServer((req, res) => { + res.end() + }) + after(() => server.close()) + server.listen(0, () => { + const url = `http://localhost:${server.address().port}` + const options = { + method: 'HEAD' + } + fetch(url, options).then(res => { + t.strictEqual(res.status, 200) + t.strictEqual(res.ok, true) + }) }) + await t.completed }) it('should encode URLs as UTF-8', async () => {