Skip to content

Commit

Permalink
Fix jest fetch polyfill by using whatwg-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Aug 7, 2024
1 parent 6f9e516 commit 30a5985
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.10.0",
"whatwg-fetch": "^3.6.20",
"xml-js": "^1.6.11",
"yaml-jest": "^1.2.0",
"yaml-loader": "^0.8.0"
Expand Down
6 changes: 0 additions & 6 deletions client/tests/jest/jest.polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ Object.defineProperties(globalThis, {
});

const { Blob, File } = require("node:buffer");
const { fetch, Headers, FormData, Request, Response } = require("undici");

Object.defineProperties(globalThis, {
fetch: { value: fetch, writable: true },
Blob: { value: Blob },
File: { value: File },
Headers: { value: Headers },
FormData: { value: FormData },
Request: { value: Request },
Response: { value: Response },
});
2 changes: 1 addition & 1 deletion client/tests/jest/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "@testing-library/jest-dom";
import "@testing-library/jest-dom/jest-globals";
import "whatwg-fetch";

import Vue from "vue";

Expand All @@ -9,7 +10,6 @@ Vue.config.devtools = false;

/* still don't understand what was invoking the following, but nothing should,
and this makes the tag tests work correctly */
global.XMLHttpRequest = undefined;
global.setImmediate = global.setTimeout;

// Always mock the following imports
Expand Down
5 changes: 5 additions & 0 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12380,6 +12380,11 @@ whatwg-encoding@^2.0.0:
dependencies:
iconv-lite "0.6.3"

whatwg-fetch@^3.6.20:
version "3.6.20"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz#580ce6d791facec91d37c72890995a0b48d31c70"
integrity sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==

whatwg-mimetype@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz#5fa1a7623867ff1af6ca3dc72ad6b8a4208beba7"
Expand Down

0 comments on commit 30a5985

Please sign in to comment.