platform-based branching in detox tests - detox

I have a test suite written in Detox and I am adding android support. In my tests some button which I don't have control over have different names between iOS and Android.
How can I have my test do a:
await element(by.text('OK')).tap(); on iOS
and
await element(by.text('Done')).tap();
on android?

You can use device.getPlatform() .
https://github.com/wix/detox/blob/master/docs/APIRef.DeviceObjectAPI.md#devicegetplatform
Example from Detox's test suite:
https://github.com/wix/detox/blob/master/detox/test/e2e/02.matchers.test.js#L18

Related

Running E2E tests with Detox and Android emulator on mac m1

I have some troubleshoot when running detox e2e tests on Android emulator with my Macbook pro m1 (Apple chipset)
I want to know if it's only me or if there is others with the same difficulty ?
I had the same issue with M1, I solved it by upgrading detox to 19.9.2
I do. Randomly having issue like this
The pending request #-1000 ("isReady") has been rejected

How to avoid multiple builds with AppCenter and Detox?

I have a question about integrating app center with Detox. Currently I have to run the following commands to build the app and then run the tests:
detox build --configuration ios.sim.release
detox test --configuration ios.sim.release --cleanup
This happens in the appcenter-pre-build.sh section. However this means that the app will be built twice, once by detox and then again by the AppCenter build process. Is there a way to stop the AppCenter process as soon as the detox tests pass? I'm thinking something along the lines of Clone -> Detox build -> run unit tests -> run detox tests -> finish.
I assume that if the detox build fails then the entire build would be invalid as it is so there is no reason to build again, right?

Detox(Android): device.reloadReactNative fails

Scenario
I am trying to test an android app for a react-native project using detox.
When running the app on a device or a simulator outside of detox, everything works.
After generating the detox build, when I run the detox test command, the app is successfully installed and opened on the simulator. When device.reloadReactNative is called via beforeEach within the tests, the app crashes with the error described below.
I put the test file and the corresponding verbose adb logcat output in a gist here.
For whatever reason the AppRegistry.js is not being loaded, otherwise the module should be known (see Error).
To wrap it up:
build and app execution work outside detox (ios+android)
detox build works (ios+android)
detox tests work on ios
when running the detox tests on android, the AppRegistry is missing after reloadReactNative is called. Why?
Env
react-native-cli: 1.3.0
react-native: 0.55.3
react-native-navigation: 1.1.457
detox-server: 7.0.0
detox: 7.3.7
OSX: 10.13.4
XCode: 9.2
Command
detox test --configuration android.emu.release --cleanup -l verbose
Error
INSTRUMENTATION_RESULT:
longMsg=com.facebook.react.common.JavascriptException: Module
AppRegistry is not a registered callable module (calling
runApplication)
Thrown here because AppRegistry has not been registered to the MessageQueue's module list.
Detox has compatibility issues with React Native Navigation v1. This will probably never be solved since Wix has already deprecated v1 in favour of v2.
You can either migrate to v2 or use the v1➜v2 adapter.
Detox has been tested on React Native Navigation v2, in fact, RNNv2 e2e test suites are using Detox on both platforms.

How to get React Native code coverage for integration tests?

I'm running React Native integration tests using Appium and Mocha.
My question is: is it possible to get a code coverage report from the integration tests?
Android Code coverage is used for android with appium. please refer the link below
android Code coverage

Hybrid Application Testing for Appium

I worked on Appium using Hybrid Application in java, Mean while the versions are Appium 1.4.0 and Eclipse Mars, Selenium 2.47.0. Dependencies jar files are download from Selenium, Appium.
Here Apk file is used for Hybrid Testing.
Please help me for the Script level.
We had similar issues in viewing html elements in our hybrid app.
We used the following code snippet in our setup() method while setting up capabilities.
Set contextNames = driver.getContextHandles();
System.out.println(contextNames); //prints out something like NATIVE_APP \n WEBVIEW_1
driver.context((String) contextNames.toArray()[1]);