Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / applications / docs / jest.setup.js
blob5627e86d806a0a09068828c21d4439ac8aa93f63
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', () => ({
17   __esModule: true,
18   loadCryptoWorker: jest.fn(),
19 }))
21 // Silence JDOM warnings triggered by emoji-mart
22 HTMLCanvasElement.prototype.getContext = jest.fn()
24 jest.mock('@proton/shared/lib/i18n/dateFnLocales', () => ({
25   __esModule: true,
26 }))
28 jest.mock('@proton/shared/lib/pow/wasmWorkerWrapper.ts', () => ({
29   __esModule: true,
30 }))
32 jest.mock('@proton/shared/lib/pow/pbkdfWorkerWrapper.ts', () => ({
33   __esModule: true,
34 }))
36 jest.mock('@proton/drive-store/store/_downloads/fileSaver/download.ts', () => {
37   return {
38     initDownloadSW: jest.fn().mockResolvedValue(true),
39   }
42 jest.mock('@proton/drive-store/store/_uploads/initUploadFileWorker.ts', () => {
43   return {
44     initUploadFileWorker: jest.fn(),
45   }
48 jest.mock('@proton/drive-store/utils/metrics/userSuccessMetrics.ts', () => {
49   return {
50       userSuccessMetrics: {
51           init: jest.fn(),
52           mark: jest.fn(),
53       },
54   };
55 });