Skip to content

Commit

Permalink
fix: mock module
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonrybczak committed Jan 14, 2025
1 parent 3886561 commit c863526
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/ui/GroupChatNameTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'
// We need a large timeout here as we are lazy loading React Navigation screens and this test is running against the entire mounted App
jest.setTimeout(50000);

jest.mock('../../modules/background-task/src/NativeReactNativeBackgroundTask', () => ({
defineTask: jest.fn(),
onBackgroundTaskExecution: jest.fn(),
}));

jest.mock('../../src/components/ConfirmedRoute.tsx');

// Needed for: https://stackoverflow.com/questions/76903168/mocking-libraries-in-jest
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/PaginationTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'
// We need a large timeout here as we are lazy loading React Navigation screens and this test is running against the entire mounted App
jest.setTimeout(60000);

jest.mock('../../modules/background-task/src/NativeReactNativeBackgroundTask', () => ({
defineTask: jest.fn(),
onBackgroundTaskExecution: jest.fn(),
}));

jest.mock('@react-navigation/native');
jest.mock('../../src/libs/Notification/LocalNotification');
jest.mock('../../src/components/Icon/Expensicons');
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/SwitchToExpensifyClassicTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const USER_A_EMAIL = '[email protected]';

jest.setTimeout(60000);

jest.mock('../../modules/background-task/src/NativeReactNativeBackgroundTask', () => ({
defineTask: jest.fn(),
onBackgroundTaskExecution: jest.fn(),
}));

jest.mock('@react-navigation/native');

TestHelper.setupApp();
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/UnreadIndicatorsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'
// We need a large timeout here as we are lazy loading React Navigation screens and this test is running against the entire mounted App
jest.setTimeout(60000);

jest.mock('../../modules/background-task/src/NativeReactNativeBackgroundTask', () => ({
defineTask: jest.fn(),
onBackgroundTaskExecution: jest.fn(),
}));

jest.mock('@react-navigation/native');
jest.mock('../../src/libs/Notification/LocalNotification');
jest.mock('../../src/components/Icon/Expensicons');
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/WorkspaceSwitcherTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'
// We need a large timeout here as we are lazy loading React Navigation screens and this test is running against the entire mounted App
jest.setTimeout(60000);

jest.mock('../../modules/background-task/src/NativeReactNativeBackgroundTask', () => ({
defineTask: jest.fn(),
onBackgroundTaskExecution: jest.fn(),
}));

jest.mock('@react-navigation/native', () => {
const actualNav = jest.requireActual<typeof Navigation>('@react-navigation/native');
return {
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/loginTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import 'react-native';
import renderer from 'react-test-renderer';
import App from '@src/App';

jest.mock('../../modules/background-task/src/NativeReactNativeBackgroundTask', () => ({
defineTask: jest.fn(),
onBackgroundTaskExecution: jest.fn(),
}));

// Needed for: https://stackoverflow.com/questions/76903168/mocking-libraries-in-jest
jest.mock('react-native/Libraries/LogBox/LogBox', () => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down

0 comments on commit c863526

Please sign in to comment.