-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathjest.setup.ts
More file actions
38 lines (32 loc) · 892 Bytes
/
jest.setup.ts
File metadata and controls
38 lines (32 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import '@testing-library/jest-dom';
import { TextDecoder, TextEncoder } from 'node:util';
/**
* Prevent the following errors with jest:
* - ReferenceError: TextEncoder is not defined
* - ReferenceError: TextDecoder is not defined
*/
if (!('TextEncoder' in globalThis)) {
(globalThis as unknown as { TextEncoder: typeof TextEncoder }).TextEncoder =
TextEncoder;
}
if (!('TextDecoder' in globalThis)) {
(globalThis as unknown as { TextDecoder: typeof TextDecoder }).TextDecoder =
TextDecoder;
}
// Mock OAuth client ID and secret
process.env.OAUTH_CLIENT_ID = 'FAKE_CLIENT_ID_123';
process.env.OAUTH_CLIENT_SECRET = 'FAKE_CLIENT_SECRET_123';
/**
* Primer Setup
*/
if (typeof CSS === 'undefined') {
global.CSS = {} as typeof CSS;
}
if (!CSS.supports) {
CSS.supports = () => true;
}
global.ResizeObserver = class {
observe() {}
unobserve() {}
disconnect() {}
};