Skip to content

Commit

Permalink
chore(frontend): polyfill jest to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Falinor committed Jan 6, 2025
1 parent 4ce9896 commit 369d6a9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 36 deletions.
6 changes: 4 additions & 2 deletions frontend/jest.polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

const { TextDecoder, TextEncoder } = require('node:util');
const { ReadableStream, TransformStream } = require('node:stream/web');
const { BroadcastChannel } = require('node:worker_threads')

Object.defineProperties(globalThis, {
ReadableStream: { value: ReadableStream },
Expand All @@ -22,13 +23,14 @@ const { Blob, File } = require('node:buffer');
const { fetch, Headers, FormData, Request, Response } = require('undici');

Object.defineProperties(globalThis, {
fetch: { value: fetch, writable: true },
fetch: { value: fetch, writable: true, configurable: true },
Blob: { value: Blob },
File: { value: File },
Headers: { value: Headers },
FormData: { value: FormData },
Request: { value: Request, configurable: true },
Response: { value: Response, configurable: true }
Response: { value: Response, configurable: true },
BroadcastChannel: { value: BroadcastChannel },
});

Object.defineProperty(window, 'matchMedia', {
Expand Down
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
"@craco/craco": "^7.1.0",
"@faker-js/faker": "^8.4.1",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"@tsconfig/create-react-app": "^2.0.5",
"@types/async": "^3.2.24",
Expand Down
58 changes: 26 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7119,7 +7119,7 @@ __metadata:
languageName: node
linkType: hard

"@testing-library/jest-dom@npm:^6.5.0":
"@testing-library/jest-dom@npm:^6.6.2, @testing-library/jest-dom@npm:^6.6.3":
version: 6.6.3
resolution: "@testing-library/jest-dom@npm:6.6.3"
dependencies:
Expand All @@ -7134,38 +7134,23 @@ __metadata:
languageName: node
linkType: hard

"@testing-library/jest-dom@npm:^6.6.2":
version: 6.6.2
resolution: "@testing-library/jest-dom@npm:6.6.2"
dependencies:
"@adobe/css-tools": "npm:^4.4.0"
aria-query: "npm:^5.0.0"
chalk: "npm:^3.0.0"
css.escape: "npm:^1.5.1"
dom-accessibility-api: "npm:^0.6.3"
lodash: "npm:^4.17.21"
redent: "npm:^3.0.0"
checksum: 10c0/1c51390f97063ce8b06a7267534aac0d6ac9b1f27042a0ae43ca52d886b32c9d2b0ff85e62e7cfeb7e1f089ef03c4d75fda4f2b7b1f08afb4bdb09a5d56566d9
languageName: node
linkType: hard

"@testing-library/react@npm:^16.0.1":
version: 16.0.1
resolution: "@testing-library/react@npm:16.0.1"
"@testing-library/react@npm:^16.1.0":
version: 16.1.0
resolution: "@testing-library/react@npm:16.1.0"
dependencies:
"@babel/runtime": "npm:^7.12.5"
peerDependencies:
"@testing-library/dom": ^10.0.0
"@types/react": ^18.0.0
"@types/react-dom": ^18.0.0
react: ^18.0.0
react-dom: ^18.0.0
"@types/react": ^18.0.0 || ^19.0.0
"@types/react-dom": ^18.0.0 || ^19.0.0
react: ^18.0.0 || ^19.0.0
react-dom: ^18.0.0 || ^19.0.0
peerDependenciesMeta:
"@types/react":
optional: true
"@types/react-dom":
optional: true
checksum: 10c0/67d05dec5ad5a2e6f92b6a3234af785435c7bb62bdbf12f3bfc89c9bca0c871a189e88c4ba023ed4cea504704c87c6ac7e86e24a3962df6c521ae89b62f48ff7
checksum: 10c0/8451dcc76ba0d4f3504af78f2a4aacc13117691f4b7a3c279f3e047d5ea817ff686496ad53e7f65f6183112aef2be3f318af609b1f5d666eed42b1014d1c68d5
languageName: node
linkType: hard

Expand Down Expand Up @@ -10648,8 +10633,8 @@ __metadata:
"@reduxjs/toolkit": "npm:^1.9.7"
"@tanstack/react-table": "npm:^8.20.5"
"@testing-library/dom": "npm:^10.4.0"
"@testing-library/jest-dom": "npm:^6.5.0"
"@testing-library/react": "npm:^16.0.1"
"@testing-library/jest-dom": "npm:^6.6.3"
"@testing-library/react": "npm:^16.1.0"
"@testing-library/user-event": "npm:^14.5.2"
"@tsconfig/create-react-app": "npm:^2.0.5"
"@turf/turf": "npm:^7.1.0"
Expand Down Expand Up @@ -19116,7 +19101,7 @@ __metadata:
languageName: node
linkType: hard

"is-shared-array-buffer@npm:^1.0.2, is-shared-array-buffer@npm:^1.0.3":
"is-shared-array-buffer@npm:^1.0.2":
version: 1.0.3
resolution: "is-shared-array-buffer@npm:1.0.3"
dependencies:
Expand All @@ -19125,6 +19110,15 @@ __metadata:
languageName: node
linkType: hard

"is-shared-array-buffer@npm:^1.0.3":
version: 1.0.4
resolution: "is-shared-array-buffer@npm:1.0.4"
dependencies:
call-bound: "npm:^1.0.3"
checksum: 10c0/65158c2feb41ff1edd6bbd6fd8403a69861cf273ff36077982b5d4d68e1d59278c71691216a4a64632bd76d4792d4d1d2553901b6666d84ade13bba5ea7bc7db
languageName: node
linkType: hard

"is-ssh@npm:^1.4.0":
version: 1.4.0
resolution: "is-ssh@npm:1.4.0"
Expand Down Expand Up @@ -19211,11 +19205,11 @@ __metadata:
linkType: hard

"is-typed-array@npm:^1.1.13":
version: 1.1.13
resolution: "is-typed-array@npm:1.1.13"
version: 1.1.15
resolution: "is-typed-array@npm:1.1.15"
dependencies:
which-typed-array: "npm:^1.1.14"
checksum: 10c0/fa5cb97d4a80e52c2cc8ed3778e39f175a1a2ae4ddf3adae3187d69586a1fd57cfa0b095db31f66aa90331e9e3da79184cea9c6abdcd1abc722dc3c3edd51cca
which-typed-array: "npm:^1.1.16"
checksum: 10c0/415511da3669e36e002820584e264997ffe277ff136643a3126cc949197e6ca3334d0f12d084e83b1994af2e9c8141275c741cf2b7da5a2ff62dd0cac26f76c4
languageName: node
linkType: hard

Expand Down Expand Up @@ -30914,7 +30908,7 @@ __metadata:
languageName: node
linkType: hard

"which-typed-array@npm:^1.1.13, which-typed-array@npm:^1.1.14, which-typed-array@npm:^1.1.15":
"which-typed-array@npm:^1.1.13, which-typed-array@npm:^1.1.15":
version: 1.1.15
resolution: "which-typed-array@npm:1.1.15"
dependencies:
Expand Down

0 comments on commit 369d6a9

Please sign in to comment.