callstack / react-native-testing-library

🦉 Simple and complete React Native testing utilities that encourage good testing practices.
https://callstack.github.io/react-native-testing-library/
MIT License
3.05k stars 270 forks source link

TypeError: Cannot read properties of undefined (reading 'debug') #1417

Closed MAsadIlyasNajum closed 1 year ago

MAsadIlyasNajum commented 1 year ago

TypeError: Cannot read properties of undefined (reading 'debug') const {debug,getByTestId} = render() please help me to solve it I'm runing a simple test case in react native cli

const App = () => Hello; describe('', () => { test('should render without crashing', () => { const {toJSON,debug} = render() }); })

My package.json { "name": "abc", "version": "1.0.8", "private": true, "scripts": { "android": "react-native run-android --variant=playStoreDebug", "ios": "react-native run-ios", "build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'", "start": "react-native start", "test": "jest --config=./jest.config.js", "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "pretty": "prettier --write 'src/*/.{tsx,ts,js}'", "generate-bundle": "react-native bundle --platform android --dev false --bundle-output android/app/src/main/assets/index.android.bundle --entry-file index.js" }, "dependencies": { "@babel/runtime": "^7.21.5", "@hmscore/react-native-hms-push": "^6.7.0-300", "@invertase/react-native-apple-authentication": "^2.2.2", "@react-native-community/checkbox": "^0.5.15", "@react-native-community/netinfo": "^9.3.10", "@react-native-firebase/analytics": "^17.5.0", "@react-native-firebase/app": "^17.5.0", "@react-native-firebase/auth": "^17.5.0", "@react-native-firebase/crashlytics": "^17.5.0", "@react-native-firebase/messaging": "^17.5.0", "@react-native-firebase/remote-config": "^17.5.0", "@react-native-google-signin/google-signin": "^9.1.0", "@react-native-masked-view/masked-view": "^0.2.9", "@react-navigation/bottom-tabs": "^6.5.7", "@react-navigation/native": "^6.1.6", "@react-navigation/stack": "^6.3.16", "@reduxjs/toolkit": "^1.9.5", "axios": "^1.4.0", "force": "^0.0.3", "i18next": "^22.5.0", "lottie-ios": "3.4.0", "lottie-react-native": "^5.1.6", "metro-react-native-babel-preset": "^0.76.5", "promise": "^8.3.0", "react": "18.2.0", "react-native": "0.71.8", "react-native-appsflyer": "^6.10.3", "react-native-config": "^1.4.11", "react-native-device-info": "^10.3.0", "react-native-fast-image": "^8.6.3", "react-native-fbsdk-next": "^10.1.0", "react-native-freshchat-sdk": "^4.2.0", "react-native-gesture-handler": "^2.10.1", "react-native-get-random-values": "^1.8.0", "react-native-gradle-plugin": "^0.71.18", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-linear-gradient": "^2.6.2", "react-native-pager-view": "^6.2.0", "react-native-permissions": "^3.8.0", "react-native-portalize": "^1.0.7", "react-native-render-html": "^6.3.4", "react-native-restart": "0.0.27", "react-native-safe-area-context": "^4.5.3", "react-native-screens": "^3.20.0", "react-native-webengage": "^1.3.0", "react-native-webview": "^12.0.3", "react-navigation": "^4.4.4", "react-redux": "^8.0.5", "uuid": "^9.0.0" }, "devDependencies": { "@babel/core": "^7.20.0", "@react-native-community/eslint-config": "^3.2.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-native": "^5.4.2", "@testing-library/react-native": "^12.1.2", "@types/jest": "^29.5.1", "@types/react-test-renderer": "^18", "@typescript-eslint/eslint-plugin": "^5.59.7", "@typescript-eslint/parser": "^5.59.7", "babel-core": "^7.0.0-bridge.0", "babel-jest": "^29.5.0", "eslint": "^8.41.0", "@types/react": "~18.2.6", "jest": "^29.3.0", "jest-environment-node": "^29.5.0", "jest-expo": "^48.0.2", "jest-fetch-mock": "^3.0.3", "jest-native": "^3.0.0", "json-format": "^1.0.1", "prettier": "^2.8.8", "react-native-clean-project": "^4.0.1", "react-native-codegen": "0.71.5", "react-test-renderer": "18.2.0", "typescript": "^5.0.4" }, "jest": { "preset": "react-native", "moduleFileExtensions": [ "ts", "tsx", "js", "jsx", "json", "node" ], "detectOpenHandles": true } }

pierrezimmermannbam commented 1 year ago

Hi @najumasad, I can't reproduce the issue with the information you have provided, could you please provide a reproduction repo or codesandbox?

mdjastrzebski commented 1 year ago

@najumasad pls create a minimal reproduction repo for your issue. Use examples/basic as a base. We need it to be able to reproduce and investigate your issue locally.

BTW your render() method should receive JSX as a first parameter.

Closing for now, will re-open issue when reproduction repo is submitted.