1- import * as NativeNavigation from '@react-navigation/native' ;
1+ import type * as ReactNavigation from '@react-navigation/native' ;
22import { render , screen } from '@testing-library/react-native' ;
33import React from 'react' ;
44import Onyx from 'react-native-onyx' ;
@@ -13,13 +13,20 @@ import ONYXKEYS from '@src/ONYXKEYS';
1313import type * as OnyxTypes from '@src/types/onyx' ;
1414import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct' ;
1515
16- jest . mock ( '@react-navigation/native' ) ;
17- const mockUseIsFocused = jest . fn ( ( ) => true ) ;
18- const mockUseRoute = jest . fn ( ( ) => ( {
19- params : { } ,
20- } ) ) ;
21- ( NativeNavigation as any ) . useIsFocused = mockUseIsFocused ;
22- ( NativeNavigation as any ) . useRoute = mockUseRoute ;
16+ const mockUseIsFocused = jest . fn ( ) . mockReturnValue ( false ) ;
17+ jest . mock ( '@react-navigation/native' , ( ) => {
18+ const actualNav = jest . requireActual < typeof ReactNavigation > ( '@react-navigation/native' ) ;
19+ return {
20+ ...actualNav ,
21+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
22+ useIsFocused : ( ) => mockUseIsFocused ( ) ,
23+ useRoute : jest . fn ( ) ,
24+ useNavigationState : jest . fn ( ) ,
25+ createNavigationContainerRef : ( ) => ( {
26+ getState : ( ) => jest . fn ( ) ,
27+ } ) ,
28+ } ;
29+ } ) ;
2330
2431jest . mock ( '@hooks/useNetwork' , ( ) => jest . fn ( ) ) ;
2532jest . mock ( '@hooks/useOnyx' , ( ) => jest . fn ( ) ) ;
@@ -40,7 +47,7 @@ jest.mock('@hooks/useLoadReportActions', () =>
4047jest . mock ( '@hooks/usePrevious' , ( ) => jest . fn ( ) ) ;
4148
4249jest . mock ( '@pages/home/report/ReportActionsList' , ( ) =>
43- jest . fn ( ( { sortedReportActions} ) => {
50+ jest . fn ( ( { sortedReportActions} : { sortedReportActions : OnyxTypes . ReportAction [ ] } ) => {
4451 if ( sortedReportActions && sortedReportActions . length > 0 ) {
4552 return null ; // Simulate normal content
4653 }
@@ -53,10 +60,6 @@ jest.mock('@libs/actions/Report', () => ({
5360 updateLoadingInitialReportAction : jest . fn ( ) ,
5461} ) ) ;
5562
56- jest . mock ( '@libs/Performance' , ( ) => ( {
57- withRenderTrace : jest . fn ( ( ) => ( Component : any ) => Component ) ,
58- } ) ) ;
59-
6063// Mock report data
6164const mockReport : OnyxTypes . Report = {
6265 reportID : '123' ,
@@ -115,6 +118,7 @@ const renderReportActionsView = (
115118 ...props ,
116119 } ;
117120
121+ // eslint-disable-next-line react/jsx-props-no-spreading
118122 return render ( < ReportActionsView { ...defaultProps } /> ) ;
119123} ;
120124
0 commit comments