diff --git a/__mocks__/@react-navigation/native/index.ts b/__mocks__/@react-navigation/native/index.ts index 5c3d3e6007ec..869f22e5133f 100644 --- a/__mocks__/@react-navigation/native/index.ts +++ b/__mocks__/@react-navigation/native/index.ts @@ -18,13 +18,13 @@ const {triggerTransitionEnd, addListener} = isJestEnv const useNavigation = isJestEnv ? realReactNavigation.useNavigation - : { - navigate: isJestEnv ? jest.fn() : () => {}, + : () => ({ + navigate: () => {}, getState: () => ({ routes: [], }), addListener, - }; + }); type NativeNavigationMock = typeof ReactNavigation & { triggerTransitionEnd: () => void; diff --git a/src/components/Search/SearchContext.tsx b/src/components/Search/SearchContext.tsx index e0904e5441c4..40e457e9ad38 100644 --- a/src/components/Search/SearchContext.tsx +++ b/src/components/Search/SearchContext.tsx @@ -1,4 +1,4 @@ -import {useNavigation} from '@react-navigation/core'; +import {useNavigation} from '@react-navigation/native'; import type {NavigationState} from '@react-navigation/routers'; import React, {useContext, useEffect, useRef, useState} from 'react'; // We need direct access to useOnyx from react-native-onyx to avoid circular dependencies in SearchContext diff --git a/tests/unit/TransactionGroupListItemTest.tsx b/tests/unit/TransactionGroupListItemTest.tsx index bee909309823..e80d24a822b4 100644 --- a/tests/unit/TransactionGroupListItemTest.tsx +++ b/tests/unit/TransactionGroupListItemTest.tsx @@ -33,6 +33,7 @@ jest.mock('@react-navigation/native', () => ({ useNavigation: () => ({ navigate: jest.fn(), addListener: jest.fn(), + getState: jest.fn(() => undefined), }), useFocusEffect: jest.fn((callback: () => void) => callback()), useRoute: () => ({