aryella-lacerda / react-native-accessibility-engine

Make accessibility-related assertions on React Native code using React Test Renderer
MIT License
163 stars 13 forks source link

react native accessibility engine not working #257

Closed Maribhuvan closed 1 year ago

Maribhuvan commented 2 years ago

Describe the bug when i run the test cases on my project. it shows below error and also i run already run test cases it shows same error... any test cases not working because of this error.

Test suite failed to run

TypeError: Cannot read properties of undefined (reading 'current')

  at warnIfNotScopedWithMatchingAct (node_modules/react-native-accessibility-engine/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14999:31)
  at updateContainer (node_modules/react-native-accessibility-engine/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16413:7)
  at create (node_modules/react-native-accessibility-engine/node_modules/react-test-renderer/cjs/react-test-renderer.development.js:17149:3)
  at Object.<anonymous> (node_modules/react-native-accessibility-engine/lib/commonjs/helpers/isReactTestInstance/isReactTestInstance.js:18:81)
  at Object.<anonymous> (node_modules/react-native-accessibility-engine/lib/commonjs/helpers/isReactTestInstance/index.js:8:51)

i have mentioned my package.json used packages,

"dependencies": { "@react-native-async-storage/async-storage": "^1.17.7", "@react-navigation/native": "^6.0.11", "@react-navigation/native-stack": "^6.7.0", "@react-navigation/stack": "^6.2.2", "amazon-cognito-identity-js": "^5.2.10", "i18next": "^21.8.16", "lodash": "^4.17.21", "react": "18.0.0", "react-hook-form": "^7.34.0", "react-i18next": "^11.18.3", "react-native": "0.69.2", "react-native-biometrics": "^2.2.0", "react-native-calendars": "^1.1287.0", "react-native-dropdown-picker": "^5.4.2", "react-native-encrypted-storage": "^4.0.2", "react-native-gesture-handler": "^2.5.0", "react-native-mask-input": "^1.2.0", "react-native-paper": "^4.12.4", "react-native-safe-area-context": "^4.3.1", "react-native-screens": "^3.15.0", "react-native-snap-carousel": "4.0.0-beta.6", "react-native-vector-icons": "^9.2.0", "styled-components": "^5.3.5" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/plugin-proposal-export-namespace-from": "^7.18.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^3.0.1", "@react-navigation/bottom-tabs": "^6.3.2", "@testing-library/jest-native": "^4.0.8", "@testing-library/react-hooks": "^8.0.1", "@testing-library/react-native": "^11.0.0", "@types/styled-components-react-native": "^5.1.3", "babel-jest": "^26.6.3", "babel-plugin-module-resolver": "^4.1.0", "babel-plugin-styled-components": "^2.0.7", "eslint": "^8.20.0", "eslint-import-resolver-babel-module": "^5.3.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jest": "^26.6.0", "husky": "^8.0.0", "jest": "^26.6.3", "lint-staged": "^13.0.3", "metro-react-native-babel-preset": "^0.70.3", "prettier": "^2.7.1", "react-native-accessibility-engine": "^2.0.0", "react-native-walkthrough-tooltip": "^1.4.0", "react-test-renderer": "18.0.0" }, "jest": { "preset": "react-native", "cacheDirectory": "./.cache", "setupFiles": [ "/jest.setup.js" ], "clearMocks": true, "setupFilesAfterEnv": [ "@testing-library/jest-native/extend-expect", "react-native-accessibility-engine" ], "collectCoverage": false, "collectCoverageFrom": [ "src/*/.js", "!src/assets/", "!src/hooks/", "!src/locales/", "!src/mocks/", "!src/utils/", "!src/themes/" ], "coverageThreshold": { "global": { "lines": 85 } }, "transformIgnorePatterns": [ "node_modules/(?!react-native|@react-native|@react-navigation)" ], "fakeTimers": { "enableGlobally": true } }, "resolutions": { "styled-components": "^5" }, "prettier": { "arrowParens": "avoid", "bracketSameLine": true, "bracketSpacing": true, "singleQuote": true, "semi": true, "trailingComma": "all", "endOfLine": "auto" }, "lint-staged": { "src/*/.js": [ "npm run lint", "npm run test:staged", "prettier --write" ] }

heathercodes commented 2 years ago

I also encountered this same issue after upgrading to React 18 + @testing-library/react-native 11. Does that mean this library is incompatible with those versions?

aryella-lacerda commented 1 year ago

@heathercodes @Maribhuvan

The problem is that v2 of this lib uses version 17 of react-test-renderer, which is incompatible with React 18, yes.

The best solution was to make react-test-renderer a peer dependency in v3. If you use React 17, you probably already have react-test-renderer@17 installed. If you use React 18, you probably already have react-test-renderer@18 installed. The installation instructions have been updated!

v3 was released a few hours ago, see the changes here: #260

If you continue to have issues, please open another issue. 😃