create-automaticgpt-template
Version:
AutomaticGPT - A production-ready Expo template with AI chat, authentication, conversation management, analytics, and sharing features
57 lines (47 loc) • 1.18 kB
JavaScript
// Jest setup file for React Native Expo project
// Mock react-native-reanimated
jest.mock('react-native-reanimated', () => {
const Reanimated = require('react-native-reanimated/mock');
// The mock for `call` immediately calls the callback which is incorrect
// So we override it with a no-op
Reanimated.default.call = () => {};
return Reanimated;
});
// Mock expo modules
jest.mock('expo-haptics', () => ({
impactAsync: jest.fn(),
ImpactFeedbackStyle: {
Light: 'light',
Medium: 'medium',
Heavy: 'heavy',
},
}));
jest.mock('@expo/vector-icons', () => ({
Ionicons: 'Ionicons',
}));
// Mock AI SDK
jest.mock('@ai-sdk/react', () => ({
useChat: jest.fn(() => ({
messages: [],
input: '',
handleInputChange: jest.fn(),
handleSubmit: jest.fn(),
isLoading: false,
error: null,
})),
}));
// Mock fetch for API tests
global.fetch = jest.fn();
// Silence console warnings during tests
global.console = {
...console,
warn: jest.fn(),
error: jest.fn(),
};
// Mock window.location for web compatibility
Object.defineProperty(window, 'location', {
value: {
origin: 'http://localhost:3000',
},
writable: true,
});