From 8aa78d81a60777b05b838d2afc06af4fb903e223 Mon Sep 17 00:00:00 2001 From: literat Date: Mon, 21 Oct 2024 14:21:56 +0200 Subject: [PATCH] Feat(jest-config): Mock TextEncoder and TextDecoder in DOM --- configs/jest-config-spirit/jsdom/setup/setupAfterEnv.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configs/jest-config-spirit/jsdom/setup/setupAfterEnv.js b/configs/jest-config-spirit/jsdom/setup/setupAfterEnv.js index b81ec5568c..f88ae5694d 100644 --- a/configs/jest-config-spirit/jsdom/setup/setupAfterEnv.js +++ b/configs/jest-config-spirit/jsdom/setup/setupAfterEnv.js @@ -1,6 +1,5 @@ -// eslint-disable-next-line import/no-extraneous-dependencies import '@testing-library/jest-dom'; -// eslint-disable-next-line import/no-extraneous-dependencies +import { TextEncoder, TextDecoder } from 'util'; import ResizeObserverPolyfill from 'resize-observer-polyfill'; /** @@ -18,3 +17,8 @@ global.ResizeObserver = ResizeObserverPolyfill; * Also consider better patching of the Console. * @see { @link https://github.com/carbon-design-system/carbon/blob/main/config/jest-config-carbon/setup/setupAfterEnv.js } */ + +/** + * While it should be bundled with jsdom, it isn't with jsdom 16. + */ +Object.assign(global, { TextDecoder, TextEncoder });