Files
expo-popcore-app/jest.setup.js
imeepos 1f9b6e22d6 feat: 添加测试框架和优化项目结构
- 添加 Jest 配置和测试设置
- 添加 use-categories hook 的单元测试
- 更新 CLAUDE.md 添加包管理工具说明
- 优化首页、视频页和频道页的组件结构
- 添加 .claude 命令配置文件
- 移除 bun.lock 和 package-lock.json,统一使用 bun
- 更新 package.json 依赖

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-19 10:53:54 +08:00

85 lines
1.7 KiB
JavaScript

import '@testing-library/jest-native/extend-expect'
// Mock react-native modules
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper')
// Mock expo modules
jest.mock('expo-constants', () => ({
default: {},
}))
jest.mock('expo-linking', () => ({
createURL: (url) => url,
parse: (url) => ({ path: url }),
}))
jest.mock('expo-secure-store', () => ({
getItemAsync: jest.fn(),
setItemAsync: jest.fn(),
deleteItemAsync: jest.fn(),
}))
jest.mock('expo-font', () => ({
useFonts: () => [true, null],
}))
jest.mock('expo-splash-screen', () => ({
preventAutoHideAsync: jest.fn(),
hideAsync: jest.fn(),
}))
// Mock react-native-reanimated
jest.mock('react-native-reanimated', () => {
const Reanimated = require('react-native-reanimated/mock')
Reanimated.default.call = () => {}
return Reanimated
})
// Mock nativewind
jest.mock('nativewind', () => ({
styled: jest.fn(),
}))
// Mock @react-navigation/native
jest.mock('@react-navigation/native', () => ({
useNavigation: () => ({
navigate: jest.fn(),
goBack: jest.fn(),
reset: jest.fn(),
}),
useRoute: () => ({
params: {},
}),
NavigationContainer: ({ children }) => children,
}))
// Mock expo-router
jest.mock('expo-router', () => ({
useRouter: () => ({
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
}),
useSegments: () => [],
usePathname: () => '/',
}))
// Global mock for console methods to reduce noise in tests
global.console = {
...console,
error: jest.fn(),
warn: jest.fn(),
log: jest.fn(),
}
// Mock @repo/core and @repo/sdk
jest.mock('@repo/core', () => ({
root: {
get: jest.fn(),
},
}))
jest.mock('@repo/sdk', () => ({
CategoryController: class MockCategoryController {},
}))