Closed ShivamJoker closed 2 years ago
@ShivamJoker we will investigate this. You can try in the meantime as a workaround to check the visibility of the first item inside the bottomsheet instead of the bottomsheet itself
@jonathanmos this brings up very old discussions regarding custom visibility thresholds (i.e. apply such in our various API's). Perhaps we should reconsider. In any case, I wonder why this works flawlessly on iOS (no visibility constraint for swipe actions?) @alon-ha we could use you advice
I was receiving the same error but in a different scenario. I don't want to distract from OP's issue but thought this information might be useful for others.
I was doing this in my global jest setup file:
beforeEach(async () => {
await device.reloadReactNative();
});
And detox was not able to identify android as being "stable" before running the tests and was throwing the "75%" error when checking for visibility of elements. I was only getting this error a low powered VM in CI (Azure DevOps Pipelines), I could not replicate this error locally, and also this error only occurred on my Android tests, no error for iOS tests.
I took some screenshots before running my visibility assertions and this is the state of the Android app:
To fix I removed await device.reloadReactNative();
from the global beforeEach and am now manually restoring state of the app after each test.
Thanks @badsyntax. The error is very generic and can stem from a vast amount of erroneous use cases.
As far as you can tell, did Detox move forward to start executing your it()
code before the app was idle? Is it possible that the app fails to load, on occasions? Please visit your device.log
files and check for errors 🙏🏻
@jonathanmos this brings up very old discussions regarding custom visibility thresholds (i.e. apply such in our various API's). Perhaps we should reconsider. In any case, I wonder why this works flawlessly on iOS (no visibility constraint for swipe actions?) @alon-ha we could use you advice
There is a visibility constraint (0.75), so same as android. My guess is that in iOS the bottom sheet open fully (DetoxSynch wait until the animation finish), and only then the visibility test is occurring) @ShivamJoker what is exactly the order of the test? Do you open the bottom sheet and only then try to check the visibility? (in such case iOS seems to work as it should). It will be good if you can post the code for the test here.
@alon-ha I am first clicking on the search button and then it opens the bottom sheet, then I tried to check it's visibility and also tried swiping it up and down.
Edit - also check the video demo it will clearly tell whats happening
The code is this
it('Open and close the search panel', async () => {
await tapOnId('search-btn');
await element(by.id('searchBox')).tap();
const commandList = element(by.id('commandList'));
await expect(commandList).toBeVisible();
await commandList.swipe('up');
await commandList.swipe('down');
await commandList.swipe('down');
});
You can check the repo as well - https://github.com/ShivamJoker/SQL-Play/blob/master/e2e/firstTest.spec.js
@ShivamJoker thanks for the quick reply.
@d4vidi From the code, it supposed to work both on iOS and Android.
After clicking the search button, the system should wait until the bottom sheet is fully opened and only then try to check the await expect(commandList).toBeVisible();
From the screenshoot in the emulator, it seems that the moment it failed (i.e the visibility check was already performed), the bottom sheet wasn't fully opened yet.
Sorry, I was getting action visibility constraints mixed up with simple visibility assertions.
I checked the video + logs and I think the conclusion is simple: that the view is indeed not 75% visible... Perhaps on the target iOS device the different device dimensions make the command list view visible, just above the threshold.
In any case, one thing I noticed was that RN's debug alerts bar blocks a part of the view. May I suggest - retry this in release mode, where the bar does not appear. If that fails, another direction is to use an emulator with a higher resolution, or - as suggested, assert the visibility of one of the inner command items. Last but not least, undeniably, the best option would be to fix this in the framework, as initially suggested. However, I can't guarantee any timelines ATM.
@d4vidi the thing is I even I tried changing the bottom sheet height to 90% and got the same error. I'll try once again and share the video.
Are you sure that changing the threshold will solve the problem and it isn't what @alon-ha is saying “it's not waiting for the bottom sheet animation to finish before the visibility check”
@ShivamJoker well that's pretty easy to test - add an await sleep()
after tapping the button. Let us know. BTW:
const sleep(ms) = new Promise((resolve) => setTimeout(resolve, ms));
🤷🏻
Okay @d4vidi, it seems to work if I set the bottom sheet height to 90% So I think I have to wait for this feature to be included and for now I will try to check the first element in the list.
Let me know if I can do anything else to contribute further.
@ShivamJoker thanks for posting this feature request! We exposed the visibility threshold as an optional parameter (see toBeVisible(pct?: number)). It will be released in the next version of Detox.
@asafkorem that's great news. Hope it will solve our issues 🎉
@asafkorem it is working great but can anyone fix the type for toBeVisible
?
typescript: Property 'toBeVisible' does not exist on type 'JestMatchers
Update: it seems to have properties if I import it from detox rather than using the global version
@ShivamJoker do you still have this error message? Also, what do you mean by "the global version"?
@asafkorem I meant if I don't require the expect from detox library it still shows the error that the property doesn't exist
If I do this the error goes
const { expect } = require('detox');
The default expect is being taken from jest
Describe the bug
I have bottom sheet which I am trying to test by swiping it up and down It seems to be working perfect in iOS but in android I am getting
Steps To Reproduce
testID
https://user-images.githubusercontent.com/23727670/126892394-80306b6a-d95d-4de0-9b16-b65fa99810d4.mov
Expected behavior
It should be able to swipe/detect the element like iOS
Detox Trace-Logs
Device logs (adb logcat)
Logs - https://gist.github.com/ShivamJoker/cb00dbf8c243f038fdb14d660adbac58
Screenshots
Environment (please complete the following information):
mocha