facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.15k stars 24.32k forks source link

Cannot tap on Switch Component in e2e tests on iOS #28032

Closed compojoom closed 1 year ago

compojoom commented 4 years ago

Description: I've reported the issue in the detox repo over here: https://github.com/wix/Detox/issues/1896 thinking that it's something related to detox, but it seems more like a bug in RN core.

Basically I have a detox test that fails randomly on the press of a Switch component. I can see the tap on the component, but the Switch is not responding. It seems to happen in around 20% of the cases.

Here is a gif: flacky-switch

That first tap wasn't registered - all the other went fine.

Here is the repo that demonstrates the issue: https://github.com/compojoom/rnDetoxActionSheetBug/tree/switch-bug

after cloning run

$ yarn

$ detox build -c ios.sim.debug

$ detox build -c ios.sim.debug

If the test succeeds - rerun it several times.

As it can be seen from the js code: https://github.com/compojoom/rnDetoxActionSheetBug/blob/switch-bug/App.js#L29;L57 - it's a pure RN app with just the Switch component on the screen.

Running the same test on android succeeds in 100% of the cases.

Moreover I've done the same test on a Native iOS app and there tapping on the switch component is always registered. So that's why I'm excluding detox as the reason for the bug. Here is a link to the native project that doesn't have this issue: https://github.com/compojoom/SwitchDetoxNative

React Native version:

$ react-native info info Fetching system and libraries information... System: OS: macOS 10.15.3 CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Memory: 1.26 GB / 32.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 13.6.0 - /usr/local/bin/node Yarn: 1.17.3 - /usr/local/bin/yarn npm: 6.13.4 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 28, 29 Build Tools: 28.0.3, 29.0.0, 29.0.2 System Images: android-24 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom Android NDK: 19.0.5232133 IDEs: Android Studio: 3.5 AI-191.8026.42.35.6010548 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5 npmGlobalPackages: create-react-native-module: 0.11.1 react-native-cli: 2.0.1

Steps To Reproduce

Please refer to the provided repository above.

Expected Results

I expect that the Switch component will respond to taps all the time in e2e tests.

Snack, code example, screenshot, or link to a repository:

Everything is provided in the description above

vvscode commented 4 years ago

Try longPress - I faced the same issue

https://github.com/wix/Detox/blob/master/docs/APIRef.ActionsOnElement.md#longpressduration

adamivancza commented 4 years ago

Long press also worked for me - I've tried both tap() and swipe('right') but none of those succeeded 100%

compojoom commented 4 years ago

ok, so longPress is the workaround? But we so far agree that this is a bug?

adamivancza commented 4 years ago

Yeah I agree that this is definitely a bug

Sommerfeld commented 4 years ago

We do face this issue, too. Also recognised it in detox test but we get the same behaviour when manually tapping (on trackpad) in the simulator while a real click on the trackpad does work.

compojoom commented 4 years ago

So you can reliably reproduce it on every tap on the trackpad?

stale[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

Fishbowler commented 4 years ago

This is still present in react-native 0.62.2, but the longPress workaround also still works ❤️

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 7 days with no activity.