From 038107ab8d705b0a0c151073fd55f04d77dcb801 Mon Sep 17 00:00:00 2001 From: Manuel Astudillo Date: Tue, 10 Sep 2024 23:35:06 +0200 Subject: [PATCH] test: add node-fetch as polifyll --- package.json | 1 + test/custom_resolver.spec.js | 1 - test/hostheader.spec.js | 5 +++-- test/onrequest.spec.js | 1 + yarn.lock | 39 ++++++++++++++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 95270d2..057daa5 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "electrode-server": "^2.2.2", "gulp": "^3.8.11", "gulp-eslint": "^0.9.0", + "node-fetch": "^3.3.2", "prettier": "^2.0.1", "run-verify": "^1.2.2", "vitest": "^2.0.5" diff --git a/test/custom_resolver.spec.js b/test/custom_resolver.spec.js index e342ea8..0d21ece 100644 --- a/test/custom_resolver.spec.js +++ b/test/custom_resolver.spec.js @@ -1,7 +1,6 @@ import { describe, it, expect } from 'vitest'; import { Redbird } from '../'; // Adjust the import path if necessary import { expect } from 'chai'; -// import _ from 'lodash'; const opts = { bunyan: false, diff --git a/test/hostheader.spec.js b/test/hostheader.spec.js index be62f2e..e46c753 100644 --- a/test/hostheader.spec.js +++ b/test/hostheader.spec.js @@ -3,7 +3,8 @@ import { describe, it, expect } from 'vitest'; import { Redbird } from '../'; // Adjust the import path if necessary import { expect } from 'chai'; -import { createServer } from 'http'; +import { createServer } from 'http'; +import fetch from 'node-fetch'; const TEST_PORT = 54674; const PROXY_PORT = 53433; @@ -97,7 +98,7 @@ describe('Target with a hostname', function () { expect(res.status).to.be.eql(502); } catch (e) { - expect(e.cause.code).to.be.eql('ECONNRESET'); + expect(e.code).to.be.eql('ECONNRESET'); } finally { await redbird.close(); } diff --git a/test/onrequest.spec.js b/test/onrequest.spec.js index 334f7da..1a04b12 100644 --- a/test/onrequest.spec.js +++ b/test/onrequest.spec.js @@ -3,6 +3,7 @@ import { describe, it, expect } from 'vitest'; import { Redbird } from '../'; // Adjust the import path if necessary import { expect } from 'chai'; +import fetch from 'node-fetch'; const { asyncVerify, runFinally } = require('run-verify'); const electrodeServer = require('electrode-server'); diff --git a/yarn.lock b/yarn.lock index 4fca280..ce79c7a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -761,6 +761,11 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +data-uri-to-buffer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz#d8feb2b2881e6a4f58c2e08acfd0e2834e26222e" + integrity sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A== + dateformat@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/dateformat/-/dateformat-2.0.0.tgz" @@ -1189,6 +1194,14 @@ fast-safe-stringify@^2.0.7: resolved "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz" integrity sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA== +fetch-blob@^3.1.2, fetch-blob@^3.1.4: + version "3.2.0" + resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.2.0.tgz#f09b8d4bbd45adc6f0c20b7e787e793e309dcce9" + integrity sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ== + dependencies: + node-domexception "^1.0.0" + web-streams-polyfill "^3.0.3" + filename-regex@^2.0.0: version "2.0.1" resolved "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz" @@ -1295,6 +1308,13 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" +formdata-polyfill@^4.0.10: + version "4.0.10" + resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" + integrity sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g== + dependencies: + fetch-blob "^3.1.2" + fs-exists-sync@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz" @@ -2295,6 +2315,11 @@ node-addon-api@^1.6.0: resolved "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.6.2.tgz" integrity sha512-479Bjw9nTE5DdBSZZWprFryHGjUaQC31y1wHo19We/k0BZlrmhqQitWoUL0cD8+scljCbIUL+E58oRDEakdGGA== +node-domexception@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" + integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== + node-etcd@^7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/node-etcd/-/node-etcd-7.0.0.tgz" @@ -2305,6 +2330,15 @@ node-etcd@^7.0.0: request "^2.87.0" url-parse "^1.4.3" +node-fetch@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.3.2.tgz#d1e889bacdf733b4ff3b2b243eb7a12866a0b78b" + integrity sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA== + dependencies: + data-uri-to-buffer "^4.0.0" + fetch-blob "^3.1.4" + formdata-polyfill "^4.0.10" + normalize-path@^2.0.1: version "2.1.1" resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz" @@ -3378,6 +3412,11 @@ wbuf@^1.1.0, wbuf@^1.7.3: dependencies: minimalistic-assert "^1.0.0" +web-streams-polyfill@^3.0.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz#2073b91a2fdb1fbfbd401e7de0ac9f8214cecb4b" + integrity sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw== + which@^1.2.12: version "1.3.0" resolved "https://registry.npmjs.org/which/-/which-1.3.0.tgz"