question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot tap on Switch Component in e2e tests on iOS

See original GitHub issue

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® Core™ 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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
vvscodecommented, Feb 17, 2020
1reaction
compojoomcommented, Mar 9, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tap on Switch component fails in around 20% of the time
I have a React-native Switch component that I need to tap on in an e2e test. In around 20% of the tests I...
Read more >
Dealing With Problems With Running Tests | Detox
This page is about issues related to executing your Detox tests, typically triggered when running detox test (and not detox build, for example)....
Read more >
Testing Switch components with Detox - react native
So I updated my tests to look like this: let toggle = element(by.id(`FirstToggle`)); await expect(toggle).toHaveValue(`0`); await toggle.tap ...
Read more >
UI Testing: tap() not triggering the button's action
UI Testing: tap() not triggering the button's action​​ I've been running this under Xcode 9.3. 1, iOS simulator, deployment target: iOS 9.3.
Read more >
Getting Started With iOS UI Testing
In Xcode's navigator pane open the test navigator. Then, in the bottom left, click the + button and choose 'New UI Test target'....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found