-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing if toasts are shown #4436
Comments
Can you reproduce it on iOS? @SamWhitby |
Probably will be explained here -> #4363 |
@gosha212, I'm actually using the package react-native-simple-toast and this is working as expected in iOS, its just Android that has the problem (it uses the ToastAndroid.show api internally). I saw #4363 which gave me hope this is possible in android and not just a limitation with the package, but i cant find anything anywhere showing how to make this work. |
@SamWhitby which Detox API do you use for testing, that works on iOS? |
@d4vidi below is the detox api i'm using that works in iOS and doesn't work in android. await expect(
element(by.text('testToastMessaage')),
).toBeVisible(); I have also tried what you suggested in android and still doesn't work. e.g. await waitFor(element(by.text('testToastMessaage')))
.toBeVisible()
.withTimeout(5000); |
@SamWhitby Could you share whether the test fails on the |
@SamWhitby As we happen to come across related things today, it appears that Android's I think you could resort to Detox's (Thanks @asafkorem) |
Apparently matching Toasts is a bit of a pain in pure Android as well - https://www.browserstack.com/guide/test-toast-message-using-espresso; We might be able to integrate a solution for that in Detox but for now UIAutomator is the best best |
What happened?
Is it possible to check if a toast is visible that is shown using the "ToastAndroid.show" api?
I have put together a simple test to illustrate. A toast is shown using ToastAndroid.show after clicking a button, and then trying to assert the toast text is shown, but the test fails trying to find the toast text.
I'm just after clarification if this is something detox is not able to test, or is there is something obvious I'm missing.
Example react component code
Example Test
Result
What was the expected behaviour?
Test should find the toast element by text.
Was it tested on latest Detox?
Did your test throw out a timeout?
Help us reproduce this issue!
No response
In what environment did this happen?
Detox version: 20.19.4
React Native version: 0.73.6
Has Fabric (React Native's new rendering system) enabled: (yes/no) no
Node version: 20.11.1
Device model: SM-T636B
Android version: 14
Test-runner (select one): jest
Detox logs
Detox logs
Device logs
Device logs
More data, please!
No response
The text was updated successfully, but these errors were encountered: