Skip to content

Commit

Permalink
Fix "ReferenceError: TextEncoder is not defined" error during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandgeider committed Jan 18, 2025
1 parent 21d8b32 commit 6e818ae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -31,4 +32,7 @@ jest.mock('./config', () => {
VITE_API_SERVER: 'https://example.com',
VITE_API_KEY: '122333444455555666666'
};
})
})

global.TextEncoder = TextEncoder as any;
global.TextDecoder = TextDecoder as any;

0 comments on commit 6e818ae

Please sign in to comment.