Skip to content

Commit

Permalink
fix jsdom environment
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Oct 15, 2024
1 parent dd694bd commit 3848900
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"devDependencies": {
"@types/fs-extra": "^9.0.13",
"@types/jest": "^29.2.0",
"@types/node": "^22.7.5",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"enzyme-adapter-react-16": "^1.15.6",
Expand Down
13 changes: 13 additions & 0 deletions src/setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import * as util from 'util';

// ref: https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
// ref: https://github.com/jsdom/jsdom/issues/2524
Object.defineProperty(global, 'TextEncoder', {
writable: true,
value: util.TextEncoder,
});

Object.defineProperty(global, 'TextDecoder', {
writable: true,
value: util.TextDecoder,
});

/* eslint-disable import/first */
global.requestAnimationFrame =
Expand Down

0 comments on commit 3848900

Please sign in to comment.