Implement comprehensive redirect logic in the Root Layout that: - Redirects unauthenticated users to login screen - Checks if authenticated users need to complete onboarding (firstName) - Prevents redirect loops by only redirecting on initial mount - Protects tabs from unauthorized access (redirects to login on logout) - Lets auth screens handle their own navigation via NavigationController Add comprehensive test suite with 8 tests covering: - Initial redirect scenarios (authenticated/unauthenticated) - Onboarding flow (missing firstName) - Logout protection - Loading states Update jest.config.js to support expo-status-bar, expo-splash-screen, react-native-reanimated, and react-native-worklets transforms. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
28 lines
959 B
JavaScript
28 lines
959 B
JavaScript
module.exports = {
|
|
preset: 'jest-expo',
|
|
testEnvironment: 'node',
|
|
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
|
transformIgnorePatterns: [
|
|
'node_modules/(?!(expo|expo-router|expo-font|expo-asset|expo-constants|expo-modules-core|expo-status-bar|expo-splash-screen|expo-file-system|@expo/.*|@expo-google-fonts/.*|@react-native|react-native|react-native-reanimated|react-native-worklets|@react-navigation|react-navigation|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg|react-native-ble-plx|react-native-base64|@stripe/.*)/)',
|
|
],
|
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
moduleNameMapper: {
|
|
'^@/(.*)$': '<rootDir>/$1',
|
|
},
|
|
collectCoverageFrom: [
|
|
'components/**/*.{ts,tsx}',
|
|
'app/**/*.{ts,tsx}',
|
|
'services/**/*.{ts,tsx}',
|
|
'contexts/**/*.{ts,tsx}',
|
|
'!**/*.d.ts',
|
|
'!**/node_modules/**',
|
|
],
|
|
globals: {
|
|
'ts-jest': {
|
|
tsconfig: {
|
|
jsx: 'react',
|
|
},
|
|
},
|
|
},
|
|
};
|