-
Notifications
You must be signed in to change notification settings - Fork 188
Fix mock passport generation #1031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -382,3 +382,29 @@ jest.mock('react-native-localize', () => ({ | |||||||||||||||||||||||||||||||||||||||||
| jest.mock('./src/utils/notifications/notificationService', () => | ||||||||||||||||||||||||||||||||||||||||||
| require('./tests/__setup__/notificationServiceMock.js'), | ||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // Mock React Navigation | ||||||||||||||||||||||||||||||||||||||||||
| jest.mock('@react-navigation/native', () => { | ||||||||||||||||||||||||||||||||||||||||||
| const actualNav = jest.requireActual('@react-navigation/native'); | ||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||
| ...actualNav, | ||||||||||||||||||||||||||||||||||||||||||
| useNavigation: jest.fn(() => ({ | ||||||||||||||||||||||||||||||||||||||||||
| navigate: jest.fn(), | ||||||||||||||||||||||||||||||||||||||||||
| goBack: jest.fn(), | ||||||||||||||||||||||||||||||||||||||||||
| canGoBack: jest.fn(() => true), | ||||||||||||||||||||||||||||||||||||||||||
| dispatch: jest.fn(), | ||||||||||||||||||||||||||||||||||||||||||
| })), | ||||||||||||||||||||||||||||||||||||||||||
| createNavigationContainerRef: jest.fn(() => ({ | ||||||||||||||||||||||||||||||||||||||||||
| current: null, | ||||||||||||||||||||||||||||||||||||||||||
| getCurrentRoute: jest.fn(), | ||||||||||||||||||||||||||||||||||||||||||
| })), | ||||||||||||||||||||||||||||||||||||||||||
| createStaticNavigation: jest.fn(() => ({ displayName: 'MockNavigation' })), | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| jest.mock('@react-navigation/native-stack', () => ({ | ||||||||||||||||||||||||||||||||||||||||||
| createNativeStackNavigator: jest.fn(() => ({ | ||||||||||||||||||||||||||||||||||||||||||
| displayName: 'MockStackNavigator', | ||||||||||||||||||||||||||||||||||||||||||
| })), | ||||||||||||||||||||||||||||||||||||||||||
| createNavigatorFactory: jest.fn(), | ||||||||||||||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+405
to
+410
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mock createNativeStackNavigator with Navigator/Screen components to avoid JSX crashes. Returning a plain object with displayName breaks usages like <Stack.Navigator>. Provide minimal components that render children. Apply: -jest.mock('@react-navigation/native-stack', () => ({
- createNativeStackNavigator: jest.fn(() => ({
- displayName: 'MockStackNavigator',
- })),
- createNavigatorFactory: jest.fn(),
-}));
+jest.mock('@react-navigation/native-stack', () => {
+ const React = require('react');
+ return {
+ createNativeStackNavigator: jest.fn(() => {
+ const Navigator = ({ children }) =>
+ React.createElement(React.Fragment, null, children);
+ const Screen = ({ children }) =>
+ React.createElement(React.Fragment, null, children);
+ return { Navigator, Screen };
+ }),
+ createNavigatorFactory: jest.fn(),
+ };
+});📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Fix createNavigationContainerRef mock to match real API (prevent isReady/navigate undefined).
Your mock omits common methods invoked on the ref (isReady, navigate, dispatch, resetRoot). This can cause runtime errors in tests/components that call them.
Apply:
📝 Committable suggestion
🤖 Prompt for AI Agents