-
Notifications
You must be signed in to change notification settings - Fork 704
Expand file tree
/
Copy pathjest.setup.js
More file actions
47 lines (37 loc) · 1.74 KB
/
Copy pathjest.setup.js
File metadata and controls
47 lines (37 loc) · 1.74 KB
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
39
40
41
42
43
44
45
46
47
import '@testing-library/jest-dom';
import '@proton/testing/lib/mockMatchMedia';
import '@proton/testing/lib/mockUnleash';
// Silence warnings on expect to throw https://github.com/testing-library/react-testing-library/issues/157
// console.error = () => {};
// console.warn = () => {};
window.ResizeObserver = jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
}));
// Do not start crypto worker pool, let the single tests setup/mock the CryptoProxy as needed
jest.mock('@proton/shared/lib/helpers/setupCryptoWorker', () => ({
__esModule: true,
loadCryptoWorker: jest.fn(),
}));
jest.mock('@proton/shared/lib/i18n/dateFnLocales', () => ({
__esModule: true,
}));
jest.mock('./src/app/locales.ts', () => ({
__esModule: true,
getLocaleMapping: () => 'en',
}));
// That's an unresolved issue of jsdom https://github.com/jsdom/jsdom/issues/918
// In particular, we need this fix to render all the components that have PaymentMethodDetails in their trees
window.SVGElement.prototype.getBBox = jest.fn().mockReturnValue({ width: 0 });
// Some components use the metrics API. If we don't mock it, tests might fail in a seemingly random manner.
// For instance, a test covering a component with metrics might finish successfully, but a subsequent test
// could fail seconds later when the metrics batch is sent via fetch.
// The metrics package has its own test coverage, so we don't need to test it here.
jest.mock('@proton/metrics');
jest.mock('@proton/components/containers/vpn/flag', () => ({
getFlagSvg: jest.fn().mockImplementation((it) => it),
}));
jest.mock('@proton/components/components/v2/phone/flagSvgs', () => ({
getFlagSvg: jest.fn().mockImplementation((it) => it),
}));