Skip to content

Commit

Permalink
fix(client): set TextEncoder in jest setup
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Dec 4, 2024
1 parent 4eaad0c commit a0dc660
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions client/jest-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//globalThis.IS_REACT_ACT_ENVIRONMENT = true;

if (!globalThis.TextEncoder || !globalThis.TextDecoder) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { TextDecoder, TextEncoder } = require("node:util");
globalThis.TextEncoder = TextEncoder;
globalThis.TextDecoder = TextDecoder;
}
4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [],
"setupFilesAfterEnv": [
"<rootDir>/jest-setup.ts"
],
"testEnvironment": "jsdom",
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
Expand Down

0 comments on commit a0dc660

Please sign in to comment.