1 import '@testing-library/jest-dom'
2 import { TextDecoder, TextEncoder } from 'util'
4 import '@proton/testing/lib/mockMatchMedia'
5 import '@proton/testing/lib/mockUnleash'
7 // Getting ReferenceError: TextDecoder is not defined without
8 global.TextEncoder = TextEncoder
9 global.TextDecoder = TextDecoder
11 // JSDom does not include a full implementation of webcrypto
12 const crypto = require('crypto').webcrypto
13 global.crypto.subtle = crypto.subtle
15 // Do not start crypto worker pool, let the single tests setup/mock the CryptoProxy as needed
16 jest.mock('@proton/shared/lib/helpers/setupCryptoWorker', () => ({
18 loadCryptoWorker: jest.fn(),
21 // Silence JDOM warnings triggered by emoji-mart
22 HTMLCanvasElement.prototype.getContext = jest.fn()
24 jest.mock('@proton/shared/lib/i18n/dateFnLocales', () => ({
28 jest.mock('@proton/shared/lib/pow/wasmWorkerWrapper.ts', () => ({
32 jest.mock('@proton/shared/lib/pow/pbkdfWorkerWrapper.ts', () => ({
36 // Some components use the metrics API. If we don't mock it, tests might fail in a seemingly random manner.
37 // For instance, a test covering a component with metrics might finish successfully, but a subsequent test
38 // could fail seconds later when the metrics batch is sent via fetch.
39 // The metrics package has its own test coverage, so we don't need to test it here.
40 jest.mock('@proton/metrics')