-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.ts
More file actions
48 lines (40 loc) · 1.63 KB
/
jest.setup.ts
File metadata and controls
48 lines (40 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
/* eslint-env jest */
// Jest setup file for Expo/React Native tests
import 'react-native-gesture-handler/jestSetup';
import { supabaseClient as mockSupabaseClient } from './db/__mocks__/supabaseClientMock';
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
// Polyfill CustomEvent for Node.js environments (required by Dexie)
// CustomEvent is a browser API that's not available in Node.js test environments
if (typeof global.CustomEvent === 'undefined') {
global.CustomEvent = class CustomEvent<T = any> extends Event {
detail: T;
constructor(type: string, eventInitDict?: CustomEventInit<T>) {
super(type, eventInitDict);
this.detail = eventInitDict?.detail as T;
}
} as any;
}
// Mock NativeWind CSS Interop - className prop requires runtime processing
// Standard practice: Mock react-native-css-interop to allow className prop without processing
jest.mock('react-native-css-interop', () => ({
styled: (component: any) => component,
cssInterop: (component: any) => component,
__esModule: true,
default: {
styled: (component: any) => component,
cssInterop: (component: any) => component,
},
}));
// Mock AsyncStorage
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
// Mock Expo modules (used across multiple tests)
jest.mock('expo-web-browser', () => ({
openAuthSessionAsync: jest.fn(),
}));
jest.mock('expo-auth-session', () => ({
makeRedirectUri: jest.fn(() => 'app.meritable://'),
}));
// Mock Supabase client (used across multiple tests)
jest.mock('./db/supabaseClient', () => ({
supabaseClient: mockSupabaseClient,
}));