Skip to content

Commit

Permalink
fix: polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
vgorkavenko committed Feb 12, 2024
1 parent 01d6ffe commit 459527b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/jest-e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"preset": "ts-jest",
"testEnvironment": "jest-environment-jsdom",
"testEnvironmentOptions": {
"customExportConditions": [""]
Expand Down
5 changes: 3 additions & 2 deletions test/jest.polyfills.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// jest.polyfills.js
/**
* @note The block below contains polyfills for Node.js globals
* required for Jest to function when running JSDOM tests.
Expand All @@ -8,13 +7,15 @@
* Consider migrating to a more modern test runner if
* you don't want to deal with this.
*/

const { clearImmediate, setImmediate } = require("node:timers")
const { TextDecoder, TextEncoder, ReadableStream } = require("node:util")

Object.defineProperties(globalThis, {
TextDecoder: { value: TextDecoder },
TextEncoder: { value: TextEncoder },
ReadableStream: { value: ReadableStream },
clearImmediate: { value: clearImmediate },
setImmediate: { value: setImmediate },
})

const { Blob, File } = require("node:buffer")
Expand Down

0 comments on commit 459527b

Please sign in to comment.