software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
6.11k stars 980 forks source link

unable to run jest tests with 2.10.0 #2488

Closed ethanneff closed 1 year ago

ethanneff commented 1 year ago

Description

Error:

    NativeViewGestureHandler must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.

Steps to reproduce

  1. upgrade from 2.9.0 to 2.10.0
  2. run yarn jest
  3. see test failure

Snack or a link to a repository

n/a

Gesture Handler version

2.10.0

React Native version

0.71.8

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 1 year ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

Aakash359 commented 1 year ago

Hello I am getting the same issues in react-native gesture-handler while runing in iOS with this command react-native run-iOS then getting this ERROR Error: PanGestureHandler must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details. in My case i have this version

{ "name": "SocialStack", "version": "1.0.3", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "TZ=etc/UTC jest", "lint": "eslint src/", "fmt": "node_modules/.bin/prettier --write \"src/*/.js\"", "postinstall": "./postinstall.sh && patch-package", "build-android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && rm -rf android/app/src/main/res/drawable- && rm -rf android/app/src/main/res/raw && rm -rf android/app/build/generated/res/resValues/release/values/", "build-ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'", "adb": "adb reverse tcp:8081 tcp:8081" }, "dependencies": { "@invertase/react-native-apple-authentication": "1.1.2", "@react-native-community/async-storage": "1.7.1", "@react-native-community/cameraroll": "git+https://github.com/BohdanSol/react-native-cameraroll.git", "@react-native-community/datetimepicker": "2.2.1", "@react-native-community/geolocation": "2.0.2", "@react-native-community/google-signin": "3.0.4", "@react-native-community/masked-view": "0.1.6", "@react-native-community/push-notification-ios": "1.10.0", "@react-native-community/slider": "2.0.9", "@react-native-firebase/analytics": "16.4.6", "@react-native-firebase/app": "16.4.6", "@react-native-firebase/messaging": "16.4.6", "@react-native-picker/picker": "^2.2.1", "adm-zip": "0.4.13", "fbjs": "^3.0.2", "lodash.debounce": "4.0.8", "moment": "2.24.0", "moment-timezone": "0.5.31", "patch-package": "^6.4.7", "plist": "3.0.1", "query-string": "^6.11.1", "ramda": "^0.27.0", "react": "17.0.2", "react-native": "0.67.1", "react-native-activity-feed": "0.8.18", "react-native-add-calendar-event": "3.0.0", "react-native-camera": "3.15.1", "react-native-fbsdk": "3.0.0", "react-native-gesture-handler": "^2.10.1", "react-native-htmlview": "0.15.0", "react-native-image-resizer": "1.1.0", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-keychain": "4.0.5", "react-native-maps": "0.26.1", "react-native-marketingcloudsdk": "7.4.3", "react-native-modal-datetime-picker": "8.1.1", "react-native-permissions": "2.0.9", "react-native-push-notification": "^3.1.9", "react-native-reanimated": "^2.14.4", "react-native-safe-area-context": "0.7.3", "react-native-screens": "2.6.0", "react-native-simple-radio-button": "2.7.4", "react-native-store-review": "0.1.5", "react-native-svg": "11.0.1", "react-native-webview": "^9.0.2", "react-navigation": "4.4.4", "react-navigation-stack": "2.0.15", "react-navigation-tabs": "2.11.1", "rn-material-ui-textfield": "1.0.5", "xcode": "2.1.0" }, "devDependencies": { "@babel/core": "7.12.9", "@babel/runtime": "7.12.5", "@react-native-community/eslint-config": "2.0.0", "babel-jest": "26.6.3", "eslint": "7.14.0", "javascript-obfuscator": "^0.27.4", "jest": "26.6.3", "jest-fetch-mock": "2.1.2", "jetifier": "^1.6.5", "metro-react-native-babel-preset": "0.66.2", "prettier": "2.0.5", "react-test-renderer": "17.0.2" }, "jest": { "globals": { "DEV": false }, "preset": "react-native", "setupFiles": [ "/jest/globals.js" ], "setupFilesAfterEnv": [ "/jest/setup.js" ], "transformIgnorePatterns": [ "node_modules/(?!((jest-)?react-native|react-navigation|@react-navigation/.))" ] }, "rnpm": { "assets": [ "./shared/project-info/assets/fonts/" ] } }

this is my pod File : require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0' install! 'cocoapods', :deterministic_uuids => false

use_frameworks! :linkage => :static

This allows different build configurations to properly inform react native that it is a debug build

However, it still creates a prod pointed build AND if you try to use the debugger it crashes and needs to be uninstalled and reinstalled

project 'BuddyUp', 'Buddy Up Staging' => :debug, 'Buddy Up Release' => :release

target 'BuddyUp' do project 'BuddyUp', $static_framework = []

This is the whole magic starts

Hit build times and times and which library ever failing add here

$static_framework += [ 'react-native-maps', 'react-native-google-maps', 'Google-Maps-iOS-Utils', 'GoogleMaps', ] pod 'GoogleSignIn'

React Native Maps dependencies

rn_maps_path = '../node_modules/react-native-maps' pod 'react-native-google-maps', :path => rn_maps_path pod 'GoogleMaps' pod 'Google-Maps-iOS-Utils'

pod 'Firebase', :modular_headers => true pod 'FirebaseCoreInternal', :modular_headers => true pod 'GoogleUtilities', :modular_headers => true

pod 'GoogleTagManager', '~> 7.0'

config = use_native_modules!

use_react_native!( :path => config[:reactNativePath],

to enable hermes on iOS, change false to true and then install pods

:hermes_enabled => false,
:fabric_enabled => false,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."

)

pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'

target 'BuddyUpTests' do inherit! :complete

Pods for testing

end

** THIS IS THE MAGIC **

pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} installer.pod_targets.each do |pod| if $static_framework.include?(pod.name) def pod.build_type; Pod::BuildType.static_library # >= 1.9 end end end end

post_install do |installer|

if !ENV['IS_CI']

#    flipper_post_install(installer)
#  end

# # This is also important AND MUST BE IN SAME ORDER
react_native_post_install(installer)
installer.pods_project.targets.each do |target|
  if target.name == 'RCT-Folly'
    target.build_configurations.each do |config|
      config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
    end
  end
end
  __apply_Xcode_12_5_M1_post_install_workaround(installer)
installer.pods_project.build_configurations.each do |config|
  config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end

end end pls help me someone to resolve this error

bbernag commented 1 year ago

I was having this error because I was using TouchableOpacity from react-native-gesture-handler instead of react-native, it also happens with ScrollView.

StephenOkeleke97 commented 1 year ago

I was having this error because I was using TouchableOpacity from react-native-gesture-handler instead of react-native, it also happens with ScrollView.

This worked for me. Thank you!

anselmoeller commented 1 year ago

I was having this error because I was using TouchableOpacity from react-native-gesture-handler instead of react-native, it also happens with ScrollView.

This was my situation too. Thank You!