/* eslint-disable */ const path = require('path') const appRoot = path.resolve(__dirname, '..') const repoRoot = path.resolve(__dirname, '../../..') // Packages that ship untranspiled ESM/JSX and must run through babel. const transformAllowList = [ '(jest-)?react-native', '@react-native(-community)?', 'expo(nent)?', '@expo(nent)?/.*', '@expo-google-fonts/.*', 'react-navigation', '@react-navigation/.*', '@unimodules/.*', 'unimodules', 'sentry-expo', 'native-base', 'react-native-svg', 'react-native-reanimated', 'react-native-gesture-handler', 'react-native-toast-message', 'react-native-webview', 'react-native-element-dropdown', 'react-native-keyboard-aware-scroll-view', 'react-native-pager-view', 'react-native-paper', 'react-native-razorpay', 'react-native-phonepe-pg', '@react-native-google-signin/.*', 'twrnc', '@trpc/.*', '@tanstack/.*', 'zustand', 'formik', 'jwt-decode', '@packages/.*', 'common-ui', ] module.exports = { preset: 'jest-expo', rootDir: __dirname, testMatch: ['/**/*.test.ts', '/**/*.test.tsx'], // Push-notification tests are commented out per AGENTS.md ("don't test push // notifications or anything related to OTP"); ignore the emptied file so Jest // does not fail it for having no tests. testPathIgnorePatterns: ['/lib/notifications.test.tsx'], setupFiles: [require.resolve('react-native-gesture-handler/jestSetup')], setupFilesAfterEnv: [path.join(__dirname, 'setup.ts')], transformIgnorePatterns: [ '/node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg|react-native-reanimated|react-native-gesture-handler|react-native-toast-message|react-native-webview|react-native-element-dropdown|react-native-keyboard-aware-scroll-view|react-native-pager-view|react-native-paper|react-native-razorpay|react-native-phonepe-pg|@react-native-google-signin/.*|@trpc/.*|@tanstack/.*|zustand|formik|jwt-decode|fuse.js|twrnc)', '/node_modules/react-native-reanimated/plugin/', ], moduleNameMapper: { // Manual mocks first (order matters: moduleNameMapper is first-match-wins). '^(.*/)?src/lib/fetch-json$': '/mocks/fetch-json.ts', // Native / platform modules -> shared shims (every copy of a package, root // or packages/ui/node_modules, resolves to the same mock). '^react-native-reanimated$': path.join(repoRoot, 'node_modules/react-native-reanimated/mock.js'), '^expo-secure-store$': '/mocks/native/secure-store.ts', '^expo-location$': '/mocks/native/location.ts', '^expo-notifications$': '/mocks/native/notifications.ts', '^expo-constants$': '/mocks/native/constants.ts', '^expo-auth-session/providers/google$': '/mocks/native/common.tsx', '^expo-auth-session$': '/mocks/native/common.tsx', '^expo-router$': '/mocks/native/expo-router.tsx', '^expo-router/(.*)$': '/mocks/native/expo-router.tsx', '^expo-image$': '/mocks/native/common.tsx', '^expo-file-system$': '/mocks/native/common.tsx', '^expo-linear-gradient$': '/mocks/native/common.tsx', '^expo-blur$': '/mocks/native/common.tsx', '^expo-status-bar$': '/mocks/native/common.tsx', '^expo-font$': '/mocks/native/common.tsx', '^expo-updates$': '/mocks/native/common.tsx', '^expo-splash-screen$': '/mocks/native/common.tsx', '^expo-web-browser$': '/mocks/native/common.tsx', '^expo-linking$': '/mocks/native/common.tsx', '^expo-haptics$': '/mocks/native/common.tsx', '^expo-image-picker$': '/mocks/native/common.tsx', '^expo-document-picker$': '/mocks/native/common.tsx', '^expo-device$': '/mocks/native/common.tsx', '^react-native-webview$': '/mocks/native/common.tsx', '^react-native-safe-area-context$': '/mocks/native/common.tsx', '^react-native-svg$': '/mocks/native/svg.tsx', '^@react-native-community/datetimepicker$': '/mocks/native/datetimepicker.tsx', '^@react-native-picker/picker$': '/mocks/native/picker.tsx', '^react-native-toast-message$': '/mocks/native/toast-message.tsx', '^react-native-razorpay$': '/mocks/native/razorpay.ts', '^react-native-phonepe-pg$': '/mocks/native/phonepe.ts', '^@react-native-google-signin/google-signin$': '/mocks/native/google-signin.ts', '^@react-navigation/native$': '/mocks/native/react-navigation.tsx', // Workspace packages. '^@packages/shared$': path.join(repoRoot, 'packages/shared'), '^@packages/shared/(.*)$': path.join(repoRoot, 'packages/shared') + '/$1', '^common-ui$': path.join(repoRoot, 'packages/ui/index.ts'), '^common-ui/(.*)$': path.join(repoRoot, 'packages/ui') + '/$1', '^@backend/(.*)$': path.join(repoRoot, 'apps/backend/src') + '/$1', // App-root alias. '^@/(.*)$': appRoot + '/$1', }, clearMocks: false, restoreMocks: false, fakeTimers: { doNotFake: ['nextTick', 'queueMicrotask', 'setImmediate'], }, testTimeout: 20000, verbose: false, maxWorkers: '50%', // Real React Query + the tRPC client can leave pending timers (e.g. a // `mode: 'pending'` fixture); force the worker down after the run. forceExit: true, }