Skip to content

Commit 1ad212e

Browse files
committed
fix setup
Signed-off-by: Adam Setch <[email protected]>
1 parent d447818 commit 1ad212e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/renderer/__helpers__/jest.setup.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ import '@testing-library/jest-dom';
22

33
import { TextDecoder, TextEncoder } from 'node:util';
44

5-
if (!global.TextEncoder || !global.TextDecoder) {
6-
/**
7-
* Prevent the following errors with jest:
8-
* - ReferenceError: TextEncoder is not defined
9-
* - ReferenceError: TextDecoder is not defined
10-
*/
11-
global.TextEncoder = TextEncoder;
12-
global.TextDecoder = TextDecoder;
5+
/**
6+
* Prevent the following errors with jest:
7+
* - ReferenceError: TextEncoder is not defined
8+
* - ReferenceError: TextDecoder is not defined
9+
*/
10+
if (!('TextEncoder' in globalThis)) {
11+
(globalThis as unknown as { TextEncoder: typeof TextEncoder }).TextEncoder =
12+
TextEncoder;
13+
}
14+
if (!('TextDecoder' in globalThis)) {
15+
(globalThis as unknown as { TextDecoder: typeof TextDecoder }).TextDecoder =
16+
TextDecoder;
1317
}
1418

1519
// Mock OAuth client ID and secret

0 commit comments

Comments
 (0)