From 0cf056958b3812165c0578f7d7847f5e091b19f3 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Tue, 25 Jul 2023 20:48:15 +0100 Subject: [PATCH] Fix broken unit tests for `FetchHttpApi.getUrl` (#3620) These tests have broken on Node.js 18.17.0. This is due to Node.js adopting an updated version of the URL parser, in which the internal `Symbol(query)` property is populated lazily. We shouldn't be relying on the internal state of the URL object anyway. Let's just compare the stringified copy. --- spec/unit/http-api/fetch.spec.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/unit/http-api/fetch.spec.ts b/spec/unit/http-api/fetch.spec.ts index 2cb5f4dd3..434d507da 100644 --- a/spec/unit/http-api/fetch.spec.ts +++ b/spec/unit/http-api/fetch.spec.ts @@ -277,11 +277,13 @@ describe("FetchHttpApi", () => { ]; const runTests = (fetchBaseUrl: string) => { it.each(testCases)( - "creates url with params %s", - ({ path, queryParams, prefix, baseUrl }, result) => { + "creates url with params %s => %s", + ({ path, queryParams, prefix, baseUrl }, expected) => { const api = makeApi(fetchBaseUrl); - expect(api.getUrl(path, queryParams, prefix, baseUrl)).toEqual(new URL(result)); + const result = api.getUrl(path, queryParams, prefix, baseUrl); + // we only check the stringified URL, to avoid having the test depend on the internals of URL. + expect(result.toString()).toEqual(expected); }, ); };