Skip to content

Getting Undefined when using render function using react native testing library #1824

Description

@Chennakiran2004

const renderAttendanceFlow = () => {
return render(


<Stack.Navigator>
<Stack.Screen
name="MarkAttendance"
component={MarkAttendancePage}
initialParams={{ navigation }}
/>
</Stack.Navigator>


)
}

this is my package.json
{
"name": "niat-student-app",
"main": "index.js",
"version": "1.0.0",
"scripts": {
"start": "expo start",
"test": "jest --watchAll"
},
"dependencies": {
"@config-plugins/detox": "11.0.0",
"@emotion/native": "^11.11.0",
"@emotion/react": "^11.14.0",
"@expo-google-fonts/roboto": "^0.4.0",
"@expo/vector-icons": "^14.1.0",
"@microsoft/react-native-clarity": "4.3.1",
"@react-native-async-storage/async-storage": "2.1.2",
"@react-native-clipboard/clipboard": "1.16.2",
"@react-native-community/datetimepicker": "^8.4.1",
"@react-native-community/netinfo": "11.4.1",
"@react-native-firebase/app": "22.2.1",
"@react-native-firebase/messaging": "22.2.1",
"@react-navigation/bottom-tabs": "^7.3.10",
"@react-navigation/elements": "^2.3.8",
"@react-navigation/native": "^7.1.6",
"@react-navigation/stack": "^7.4.8",
"@sentry/react-native": "^6.14.0",
"@shopify/flash-list": "1.7.6",
"@types/react-native-snap-carousel": "^3.8.11",
"@types/styled-components": "^5.1.34",
"@types/styled-components-react-native": "^5.2.5",
"apisauce": "^3.1.1",
"aws-sdk": "^2.1692.0",
"buffer": "^6.0.3",
"expo": "53.0.20",
"expo-blur": "~14.1.5",
"expo-checkbox": "4.1.4",
"expo-clipboard": "~7.1.5",
"expo-constants": "~17.1.6",
"expo-crypto": "~14.1.5",
"expo-dev-client": "~5.2.4",
"expo-device": "~7.1.4",
"expo-document-picker": "^13.1.6",
"expo-font": "~13.3.1",
"expo-haptics": "~14.1.4",
"expo-image": "~2.4.0",
"expo-linear-gradient": "~14.1.5",
"expo-linking": "~7.1.7",
"expo-local-authentication": "~16.0.5",
"expo-router": "~5.1.4",
"expo-speech-recognition": "^2.1.0",
"expo-splash-screen": "~0.30.10",
"expo-status-bar": "~2.2.3",
"expo-symbols": "~0.4.5",
"expo-system-ui": "~5.0.10",
"expo-updates": "~0.28.17",
"expo-web-browser": "~14.2.0",
"i18next": "21.3.2",
"i18next-xhr-backend": "3.2.2",
"js-sha256": "0.11.1",
"mobx": "6.13.7",
"mobx-react": "9.2.0",
"mobx-react-lite": "4.1.0",
"process": "^0.11.10",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-i18next": "11.12.0",
"react-native": "0.79.5",
"react-native-calendars": "^1.1313.0",
"react-native-config": "1.5.5",
"react-native-device-info": "^14.0.4",
"react-native-gesture-handler": "~2.24.0",
"react-native-get-random-values": "1.11.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-keyboard-controller": "^1.17.5",
"react-native-markdown-display": "^7.0.2",
"react-native-modal-datetime-picker": "^18.0.0",
"react-native-pager-view": "^6.7.1",
"react-native-paper": "5.14.5",
"react-native-paper-dates": "^0.22.43",
"react-native-permissions": "5.4.1",
"react-native-reanimated": "~3.17.4",
"react-native-render-html": "6.3.4",
"react-native-safe-area-context": "5.4.0",
"react-native-screens": "~4.11.1",
"react-native-snap-carousel": "^3.9.1",
"react-native-svg": "^15.11.2",
"react-native-toast-message": "2.3.0",
"react-native-vector-icons": "10.2.0",
"react-native-web": "~0.20.0",
"react-native-webengage": "1.6.0",
"react-native-webview": "13.13.5",
"styled-components": "^6.1.18",
"uuid": "11.1.0",
"zustand": "^5.0.5"
},
"engines": {
"node": "20.18.1",
"npm": ">=10.0.0"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@react-native-community/cli": "^18.0.0",
"@testing-library/react-native": "^12.8.0",
"@tsconfig/react-native": "^3.0.5",
"@types/jest": "^30.0.0",
"@types/react": "~19.0.10",
"@types/react-native-vector-icons": "^6.4.18",
"cross-env": "10.0.0",
"eslint": "^9.25.0",
"eslint-config-expo": "~9.2.0",
"jest": "~29.7.0",
"jest-expo": "~53.0.10",
"patch-package": "^8.0.0",
"typescript": "~5.8.3"
},
"jest": {
"preset": "jest-expo",
"setupFilesAfterEnv": [
"@testing-library/react-native/jest-preset"
],
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.|@expo-google-fonts/.|react-navigation|@react-navigation/.|@sentry/react-native|native-base|react-native-svg|@testing-library|uuid)"
],
"moduleNameMapper": {
"^@/(.
)$": "/$1"
}
},
"private": true
}

Error Message :

  The above error occurred in the <ThrowError> component.
  
  React will try to recreate this component tree from scratch using the error boundary you provided, ErrorBoundary.
  

  155 |
  156 |   test('9. handles null fallback', () => {
> 157 |     const { getByText } = render(
      |                                 ^
  158 |       <TestErrorBoundary fallback={null}>
  159 |         <ThrowError shouldThrow={true} />
  160 |       </TestErrorBoundary>

  at defaultOnCaughtError (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:5114:21)
  at logCaughtError (node_modules/react-test-re

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions