diff --git a/config/jest/test-setup.js b/config/jest/test-setup.js index f643bb02f..a41691966 100644 --- a/config/jest/test-setup.js +++ b/config/jest/test-setup.js @@ -3,9 +3,26 @@ const {StyleSheetTestUtils} = require("aphrodite"); const { mockRequestAnimationFrame, } = require("../../utils/testing/mock-request-animation-frame"); +const {TextEncoder, TextDecoder} = require("util"); StyleSheetTestUtils.suppressStyleInjection(); + +const attachShims = (targetWindow) => { + if (!targetWindow.TextEncoder) { + targetWindow.TextEncoder = TextEncoder; + } + if (!targetWindow.TextDecoder) { + targetWindow.TextDecoder = TextDecoder; + } +} + +const resetWindow = () => { + attachShims(globalThis); +}; +resetWindow(); + beforeEach(() => { + resetWindow(); mockRequestAnimationFrame(); });