From 6e818ae25f20a14e3e45d71d00a0340f462bf298 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sat, 18 Jan 2025 12:15:35 +0100 Subject: [PATCH] Fix "ReferenceError: TextEncoder is not defined" error during tests --- src/setupTests.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/setupTests.ts b/src/setupTests.ts index cb1aa44e..1dee4cdf 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -5,6 +5,7 @@ import '@testing-library/jest-dom'; import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; +import { TextDecoder, TextEncoder } from 'util'; // Mock the translations i18n.use(initReactI18next).init({ @@ -31,4 +32,7 @@ jest.mock('./config', () => { VITE_API_SERVER: 'https://example.com', VITE_API_KEY: '122333444455555666666' }; -}) \ No newline at end of file +}) + +global.TextEncoder = TextEncoder as any; +global.TextDecoder = TextDecoder as any; \ No newline at end of file