Skip to content

Commit

Permalink
TEMP: Jest/JSDOM does not yet implement core JS behaviors from Node 17
Browse files Browse the repository at this point in the history
  • Loading branch information
barmintor committed Feb 2, 2025
1 parent 8de44c5 commit a00ca4c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions __tests__/utils/PatchedJSDOMEnvironment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import JSDOMEnvironment from 'jest-environment-jsdom';

/**
* JSDOM has a documented issue re: missing support of core JS available since Node 17
* e.g. https://github.com/jsdom/jsdom/issues/1721
* e.g. https://github.com/jsdom/jsdom/issues/3363
*/
export default class PatchedJSDOMEnvironment extends JSDOMEnvironment {
/** */
constructor(...args) {
super(...args);

// delegate to node for structuredClone
this.global.structuredClone = structuredClone;
}
}
2 changes: 1 addition & 1 deletion jest.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!@react-dnd|react-dnd|dnd-core|react-dnd-html5-backend|dnd-multi-backend|rdndmb-html5-to-touch|react-mosaic-component2|lodash-es)"
],
"testEnvironment": "jsdom"
"testEnvironment": "<rootDir>/__tests__/utils/PatchedJSDOMEnvironment.js"
}, {
"displayName": "integration",
"moduleDirectories": [
Expand Down

0 comments on commit a00ca4c

Please sign in to comment.