1 import '@testing-library/jest-dom';
2 import { TextDecoder, TextEncoder } from 'util';
4 /* Getting ReferenceError: TextDecoder is not defined without */
5 global.TextEncoder = TextEncoder;
6 global.TextDecoder = TextDecoder;
8 /* Do not start crypto worker pool, let the single tests setup/mock
9 * the CryptoProxy as needed */
10 jest.mock('@proton/shared/lib/helpers/setupCryptoWorker', () => ({
12 loadCryptoWorker: jest.fn(),
15 jest.mock('loglevel');
17 /* JSDom does not include webcrypto */
18 const crypto = require('crypto').webcrypto;
19 global.crypto.subtle = crypto.subtle;
20 global.VERSION = '0.0.1';
22 /** JSDom has an inconsistent `postMessage` implementation:
23 * It lacks support for falling back to `/` as the `targetOrigin`.
24 * Additionally, setting the `targetOrigin` to `/` is not supported
25 * due to a missing reference to the source window.
26 * See: https://github.com/jsdom/jsdom/blob/main/lib/jsdom/living/post-message.js */
27 const originalPostMessage = window.postMessage.bind(window);
28 window.postMessage = (message, _, transferable) => originalPostMessage(message, '*', transferable);