-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjestSetupFile.js
More file actions
26 lines (23 loc) · 914 Bytes
/
jestSetupFile.js
File metadata and controls
26 lines (23 loc) · 914 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
// See: https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#configuring-your-testing-environment
global.IS_REACT_ACT_ENVIRONMENT = true;
// Fixes errors in tests, when components from vscode-webview-ui-toolkit are used.
if (typeof window !== 'undefined') { // Only in jsdom
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});
const { TextDecoder, TextEncoder } = require('node:util')
Object.defineProperties(globalThis, {
TextDecoder: { value: TextDecoder },
TextEncoder: { value: TextEncoder },
});
}