-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjest-setup.ts
More file actions
56 lines (51 loc) · 1.63 KB
/
jest-setup.ts
File metadata and controls
56 lines (51 loc) · 1.63 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
48
49
50
51
52
53
54
55
56
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import '@testing-library/jest-dom';
import 'core-js';
import { indexedDB } from 'fake-indexeddb';
import 'jest-canvas-mock';
import 'jest-location-mock';
import { TextDecoder, TextEncoder } from 'util';
// was needed for github actions environment
import matchMediaMock from 'match-media-mock';
import React from 'react';
window.matchMedia ??= matchMediaMock.create(); // required for rendering ant design components, specifically at time of addition, the steps component.
global.React = React;
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
global.performance.markResourceTiming = jest.fn();
global.fetch = require('node-fetch');
global.indexedDB = indexedDB;
// Mock URL.createObjectURL and revokeObjectURL for image preview tests
let blobCounter = 0;
global.URL.createObjectURL = jest.fn(() => {
blobCounter++;
return `blob:http://localhost:3000/mock-blob-url-${blobCounter}`;
});
global.URL.revokeObjectURL = jest.fn();
// forcefully mock crypto
Object.defineProperty(global, 'crypto', {
value: {
subtle: {
digest: jest.fn(),
generateKey: jest.fn(),
importKey: jest.fn(),
exportKey: jest.fn(),
sign: jest.fn(),
},
},
});
// Mock import.meta for tests
global.import = {
meta: {
env: {
VITE_ARWEAVE_HOST: 'arweave.net',
VITE_ARWEAVE_GRAPHQL_URL: 'https://arweave.net/graphql',
VITE_HYPERBEAM_URL: undefined,
VITE_ARIO_PROCESS_ID: undefined,
VITE_NODE_ENV: 'test',
VITE_ARIO_AO_CU_URL: 'https://cu.ardrive.io',
VITE_ANT_AO_CU_URL: 'https://cu.ardrive.io',
},
},
};