-
Notifications
You must be signed in to change notification settings - Fork 25
/
setupTests.js
35 lines (31 loc) · 992 Bytes
/
setupTests.js
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
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
import { LogBox } from 'react-native';
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
jest.mock('i18next', () => {
const originalI18next = jest.requireActual('i18next');
return {
...originalI18next,
use: jest.fn().mockReturnThis(),
init: jest.fn().mockImplementation((options, callback) => {
if (callback) callback();
return Promise.resolve();
}),
t: jest.fn().mockImplementation(key => key), // Simple mock implementation for translations
language: 'en'
};
});
jest.mock('react-i18next', () => ({
...jest.requireActual('react-i18next'),
initReactI18next: {
type: '3rdParty',
init: jest.fn()
},
useTranslation: () => ({
t: jest.fn().mockImplementation(key => key),
i18n: {
changeLanguage: jest.fn().mockResolvedValue('en'),
language: 'en'
}
})
}));
LogBox.ignoreAllLogs();