Trying to test sample app for a react-native project using detox. While running the app on a simulator using react-native run-android (outside of detox), App is getting installed and launched successfully. After generating the detox build, when I run the detox test command, app is not getting launched & test fails
Detox: 9.0.4;
React-native-cli: 2.0.1
react-native: 0.57.1
Node: 10.11.0
Device: Android Studio emulator: Nexus_5X_API_26
OS: Windows 8.1
E:\FourTest>detox test --configuration android.emu.debug -l verbose
configuration="android.emu.debug" loglevel="verbose" artifactsLocation="artifact
s\android.emu.debug.2018-10-04 12-00-03Z" node_modules.bin\jest e2e --config=e
2e/config.json --maxWorkers=1 "--testNamePattern=^((?!:ios:).)$"
detox[8900] INFO: [DetoxServer.js] server listening on localhost:62341...
detox[8900] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws:/
/localhost:62341
detox[8900] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=01783f0e-0f21-a
9f2-b807-53742114f4c4
detox[8900] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=01783f0
e-0f21-a9f2-b807-53742114f4c4
detox[8900] DEBUG: [exec.js/EXEC_CMD, #0] C:\AndriodSDK\sdk\tools\emulator -list
-avds --verbose
detox[8900] DEBUG: [exec.js/EXEC_CMD, #1] C:\AndriodSDK\sdk\platform-tools\adb
devices
detox[8900] DEBUG: [exec.js/EXEC_CMD, #2] C:\AndriodSDK\sdk\platform-tools\adb -
s emulator-5554 shell "getprop dev.bootcomplete"
detox[8900] DEBUG: [exec.js/EXEC_CMD, #3] C:\AndriodSDK\sdk\platform-tools\adb -
s emulator-5554 shell "getprop ro.build.version.sdk"
detox[8900] DEBUG: [exec.js/EXEC_CMD, #4] C:\AndriodSDK\sdk\platform-tools\adb -
s emulator-5554 shell "dumpsys power | grep \"^[ ]m[UW].*=\""
detox[8900] DEBUG: [exec.js/EXEC_CMD, #5] C:\AndriodSDK\sdk\build-tools\27.0.3\a
apt dump badging "E:\FourTest\android\app\build\outputs\apk\debug\app-debug.apk"
| findstr /C:"package: name="
detox[8900] DEBUG: [exec.js/EXEC_CMD, #6] C:\AndriodSDK\sdk\platform-tools\adb -
s emulator-5554 shell "pm list packages com.fourtest"
detox[8900] DEBUG: [exec.js/EXEC_CMD, #7] C:\AndriodSDK\sdk\platform-tools\adb -
s emulator-5554 uninstall com.fourtest
detox[8900] DEBUG: [exec.js/EXEC_CMD, #8] C:\AndriodSDK\sdk\platform-tools\adb -
s emulator-5554 shell "pm list packages com.fourtest.test"
detox[8900] DEBUG: [exec.js/EXEC_CMD, #9] C:\AndriodSDK\sdk\platform-tools\adb -
s emulator-5554 uninstall com.fourtest.test
detox[8900] DEBUG: [exec.js/EXEC_CMD, #10] C:\AndriodSDK\sdk\platform-tools\adb
-s emulator-5554 install -r -g E:\FourTest\android\app\build\outputs\apk\debug\a
pp-debug.apk
detox[8900] DEBUG: [exec.js/EXEC_CMD, #11] C:\AndriodSDK\sdk\platform-tools\adb
-s emulator-5554 install -r -g E:\FourTest\android\app\build\outputs\apk\android
Test\debug\app-debug-androidTest.apk
detox[8900] DEBUG: [exec.js/EXEC_CMD, #12] C:\AndriodSDK\sdk\platform-tools\adb
-s emulator-5554 shell "am force-stop com.fourtest"
detox[8900] DEBUG: [exec.js/EXEC_CMD, #13] C:\AndriodSDK\sdk\platform-tools\adb
-s emulator-5554 shell "pm list instrumentation"
detox[8900] DEBUG: [exec.js/SPAWN_CMD, #14] [pid=10328] C:\AndriodSDK\sdk\platfo
rm-tools\adb -s emulator-5554 shell am instrument -w -r "-e detoxServer ws://loc
alhost:62341 -e detoxSessionId 01783f0e-0f21-a9f2-b807-53742114f4c4" -e debug fa
lse com.fourtest.test/android.test.InstrumentationTestRunner
detox[8900] DEBUG: [exec.js/EXEC_CMD, #15] C:\AndriodSDK\sdk\platform-tools\adb
-s emulator-5554 shell "ps | grep \"com.fourtest$\""
detox[8900] ERROR: [exec.js/EXEC_FAIL, #15] "C:\AndriodSDK\sdk\platform-tools\ad
b -s emulator-5554 shell "ps | grep \"com.fourtest$\""" failed with code = 1, s
tdout and stderr:
detox[8900] ERROR: [exec.js/EXEC_FAIL, #15]
detox[8900] ERROR: [exec.js/EXEC_FAIL, #15]
detox[8900] DEBUG: [exec.js/EXEC_CMD, #16] C:\AndriodSDK\sdk\platform-tools\adb
-s emulator-5554 shell "ps | grep \"com.fourtest$\""
detox[8900] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, ca
nnot fw action (sessionId=01783f0e-0f21-a9f2-b807-53742114f4c4)
detox[8900] DEBUG: [exec.js/KILL] sending SIGINT to [pid = 10328]: C:\AndriodSDK
\sdk\platform-tools\adb -s emulator-5554 shell am instrument -w -r -e detoxServe
r ws://localhost:62341 -e detoxSessionId 01783f0e-0f21-a9f2-b807-53742114f4c4 -e
debug false com.fourtest.test/android.test.InstrumentationTestRunner
FAIL e2e/firstTest.spec.js (128.093s)
Example
x should have welcome screen (30ms)
x should show hello screen after tap (5ms)
? Example > should have welcome screen
Timeout - Async callback was not invoked within the 120000ms timeout specifi
ed by jest.setTimeout.
at mapper (../node_modules/jest-jasmine2/build/queue_runner.js:41:52)
? Example > should have welcome screen
ReferenceError: device is not defined
1 | describe('Example', () => {
2 | beforeEach(async () => {
> 3 | await device.reloadReactNative();
| ^
4 | });
5 |
6 | it('should have welcome screen', async () => {
at Object.beforeEach (firstTest.spec.js:3:5)
? Example > should have welcome screen
ReferenceError: element is not defined
5 |
6 | it('should have welcome screen', async () => {
> 7 | await expect(element(by.text('FourTest'))).toBeVisible();
| ^
8 | });
9 |
10 | it('should show hello screen after tap', async () => {
at Object.it (firstTest.spec.js:7:5)
? Example > should show hello screen after tap
Timeout - Async callback was not invoked within the 120000ms timeout specifi
ed by jest.setTimeout.
at mapper (../node_modules/jest-jasmine2/build/queue_runner.js:41:52)
? Example > should show hello screen after tap
ReferenceError: device is not defined
1 | describe('Example', () => {
2 | beforeEach(async () => {
> 3 | await device.reloadReactNative();
| ^
4 | });
5 |
6 | it('should have welcome screen', async () => {
at Object.beforeEach (firstTest.spec.js:3:5)
? Example > should show hello screen after tap
ReferenceError: element is not defined
9 |
10 | it('should show hello screen after tap', async () => {
> 11 | await element(by.text('FourTest')).tap();
| ^
12 | await expect(element(by.text('Welcome to React Native!'))).toBeVi
sible().withTimeout(2000);
13 | });
14 | })
at Object.it (firstTest.spec.js:11:5)
Test Suites: 1 failed, 1 total
Tests: 2 failed, 2 total
Snapshots: 0 total
Time: 128.541s
Ran all test suites matching /e2e/i with tests matching "^((?!:ios:).)*$".
detox[8900] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=01783f0e-0
f21-a9f2-b807-53742114f4c4
child_process.js:651
throw err;
^
Error: Command failed: node_modules.bin\jest e2e --config=e2e/config.json --max
Workers=1 "--testNamePattern=^((?!:ios:).)*$"
at checkExecSyncError (child_process.js:611:11)
at Object.execSync (child_process.js:648:13)
at runJest (E:\FourTestnode_modules\detox\local-cli\detox-test.js:154:6)
at run (E:\FourTestnode_modules\detox\local-cli\detox-test.js:85:7)
at Object.
s:217:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Well, most likely it crashes. See your adb logcat to find out why.
I get the same, but also on iOS. @noomorph can u check previous issue I have opened, please?
Adding logcat txt
--------- beginning of system
10-05 08:35:08.655 1506 1506 I vold : Vold 3.0 (the awakening) firing up
10-05 08:35:08.655 1506 1506 V vold : Detected support for: ext4 vfat
10-05 08:35:08.663 1506 1506 W vold : Failed to LOOP_GET_STATUS64 /dev/block/loop6: No such device or address
10-05 08:35:08.681 1506 1506 W vold : Failed to LOOP_GET_STATUS64 /dev/block/loop4: No such device or address
10-05 08:35:08.720 1506 1506 W vold : Failed to LOOP_GET_STATUS64 /dev/block/loop2: No such device or address
10-05 08:35:08.751 1506 1506 W vold : Failed to LOOP_GET_STATUS64 /dev/block/loop0: No such device or address
10-05 08:35:08.791 1506 1506 W vold : Failed to LOOP_GET_STATUS64 /dev/block/loop7: No such device or address
10-05 08:35:08.831 1506 1506 W vold : Failed to LOOP_GET_STATUS64 /dev/block/loop5: No such device or address
10-05 08:35:08.871 1506 1506 W vold : Failed to LOOP_GET_STATUS64 /dev/block/loop3: No such device or address
10-05 08:35:08.901 1506 1506 W vold : Failed to LOOP_GET_STATUS64 /dev/block/loop1: No such device or address
10-05 08:35:08.934 1506 1506 D vold : VoldNativeService::start() completed OK
10-05 08:35:08.938 1506 1514 D vold : e4crypt_init_user0
10-05 08:35:08.939 1506 1514 D vold : e4crypt_prepare_user_storage for volume null, user 0, serial 0, flags 1
10-05 08:35:08.940 1506 1514 D vold : Preparing: /data/system/users/0
10-05 08:35:08.940 1506 1514 D vold : Preparing: /data/misc/profiles/cur/0
10-05 08:35:08.940 1506 1514 D vold : Preparing: /data/system_de/0
10-05 08:35:08.940 1506 1514 D vold : Preparing: /data/misc_de/0
10-05 08:35:08.940 1506 1514 D vold : Preparing: /data/vendor_de/0
10-05 08:35:08.955 1506 1514 D vold : Preparing: /data/user_de/0
10-05 08:35:08.955 1506 1514 V vold : /system/bin/vold_prepare_subdirs
10-05 08:35:08.955 1506 1514 V vold : prepare
10-05 08:35:08.955 1506 1514 V vold :
10-05 08:35:08.955 1506 1514 V vold : 0
10-05 08:35:08.955 1506 1514 V vold : 1
10-05 08:35:08.957 1506 1515 I vold : Found disk at /devices/pci0000:00/0000:00:08.0/virtio5/block/vdf but delaying scan due to secure keyguard
10-05 08:35:08.980 1506 1514 D vold : e4crypt_unlock_user_key 0 serial=0 token_present=0
10-05 08:35:08.980 1506 1514 E vold : Failed to chmod /data/system_ce/0: No such file or directory
10-05 08:35:08.980 1506 1514 E vold : Failed to chmod /data/misc_ce/0: No such file or directory
10-05 08:35:08.981 1506 1514 E vold : Failed to chmod /data/media/0: No such file or directory
10-05 08:35:09.560 1577 1577 I [email protected]: Wifi Hal is booting up...
10-05 08:35:09.682 1506 1595 I Cryptfs : cryptfs_check_passwd
10-05 08:35:09.683 1506 1595 D Cryptfs : crypt_ftr->fs_size = 4194304
10-05 08:35:09.683 1506 1595 I Cryptfs : Using scrypt for cryptfs KDF
10-05 08:35:10.017 1506 1595 I Cryptfs : Extra parameters for dm_crypt: 1 allow_discards
10-05 08:35:10.051 1506 1515 D vold : Disk at 252:0 changed
10-05 08:35:10.288 1506 1595 I Cryptfs : Password matches
10-05 08:35:10.289 1506 1595 D Cryptfs : test_mount_encrypted_fs(): Master key saved
10-05 08:35:10.296 1506 1595 I vold : List of Keymaster HALs found:
10-05 08:35:10.296 1506 1595 I vold : Keymaster HAL #1: SoftwareKeymasterDevice from Google SecurityLevel: SOFTWARE HAL: [email protected]::IKeymasterDevice/default
10-05 08:35:10.298 1506 1595 I vold : Using SoftwareKeymasterDevice from Google for encryption. Security level: SOFTWARE, HAL: [email protected]::IKeymasterDevice/default
10-05 08:35:10.299 1506 1595 D Cryptfs : Password is default - restarting filesystem
10-05 08:35:10.321 1506 1595 D Cryptfs : unmounting /data succeeded
10-05 08:35:10.333 1506 1595 I vold : [libfs_mgr]superblock s_max_mnt_count:65535,/dev/block/dm-0
10-05 08:35:10.334 1506 1595 I vold : [libfs_mgr]Filesystem on /dev/block/dm-0 was not cleanly shutdown; state flags: 0x1, incompat feature flags: 0x46
10-05 08:35:10.354 1506 1595 I vold : [libfs_mgr]check_fs(): mount(/dev/block/dm-0,/data,ext4)=0: Success
10-05 08:35:10.397 1506 1595 I vold : [libfs_mgr]check_fs(): unmount(/data) succeeded
10-05 08:35:10.398 1506 1595 I vold : [libfs_mgr]Running /system/bin/e2fsck on /dev/block/dm-0
10-05 08:35:10.711 1506 1595 I vold : [libfs_mgr]__mount(source=/dev/block/dm-0,target=/data,type=ext4)=0: Success
10-05 08:35:10.720 1506 1595 D Cryptfs : Just triggered post_fs_data
10-05 08:35:10.832 1506 1517 D vold : e4crypt_init_user0
10-05 08:35:10.832 1506 1517 D vold : e4crypt_prepare_user_storage for volume null, user 0, serial 0, flags 1
10-05 08:35:10.832 1506 1517 D vold : Preparing: /data/system/users/0
10-05 08:35:10.834 1506 1517 D vold : Preparing: /data/misc/profiles/cur/0
10-05 08:35:10.836 1506 1517 D vold : Preparing: /data/system_de/0
10-05 08:35:10.838 1506 1517 D vold : Preparing: /data/misc_de/0
10-05 08:35:10.840 1506 1517 D vold : Preparing: /data/vendor_de/0
10-05 08:35:10.841 1506 1517 D vold : Preparing: /data/user_de/0
10-05 08:35:10.841 1506 1517 V vold : /system/bin/vold_prepare_subdirs
10-05 08:35:10.841 1506 1517 V vold : prepare
10-05 08:35:10.841 1506 1517 V vold :
10-05 08:35:10.842 1506 1517 V vold : 0
10-05 08:35:10.842 1506 1517 V vold : 1
10-05 08:35:10.858 1506 1517 D vold : e4crypt_unlock_user_key 0 serial=0 token_present=0
10-05 08:35:10.891 1506 1595 D Cryptfs : post_fs_data done
10-05 08:35:10.894 1506 1595 D Cryptfs : Just triggered restart_framework
10-05 08:35:11.296 1668 1668 I installd: installd firing up
10-05 08:35:11.616 1680 1680 I wificond: wificond is starting up...
--------- beginning of crash
10-05 08:35:11.652 1663 1663 F libc : Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 1663 (surfaceflinger), pid 1663 (surfaceflinger)
10-05 08:35:11.720 1717 1717 F DEBUG : *
10-05 08:35:11.720 1717 1717 F DEBUG : Build fingerprint: 'google/sdk_gphone_x86/generic_x86:9/PSR1.180720.012/4923214:user/release-keys'
10-05 08:35:11.720 1717 1717 F DEBUG : Revision: '0'
10-05 08:35:11.720 1717 1717 F DEBUG : ABI: 'x86'
10-05 08:35:11.720 1717 1717 F DEBUG : pid: 1663, tid: 1663, name: surfaceflinger >>> /system/bin/surfaceflinger <<<
10-05 08:35:11.720 1717 1717 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
10-05 08:35:11.720 1717 1717 F DEBUG : Abort message: 'Status.cpp:149] Failed HIDL return status not checked: Status(EX_TRANSACTION_FAILED): 'DEAD_OBJECT: ''
10-05 08:35:11.720 1717 1717 F DEBUG : eax 00000000 ebx 0000067f ecx 0000067f edx 00000006
10-05 08:35:11.721 1717 1717 F DEBUG : edi 0000067f esi ec7f3048
10-05 08:35:11.721 1717 1717 F DEBUG : ebp fffdaeb8 esp fffdae38 eip ed8f9b59
10-05 08:35:11.736 1717 1717 F DEBUG :
10-05 08:35:11.736 1717 1717 F DEBUG : backtrace:
10-05 08:35:11.736 1717 1717 F DEBUG : #00 pc 00000b59 [vdso:ed8f9000] (__kernel_vsyscall+9)
10-05 08:35:11.736 1717 1717 F DEBUG : #01 pc 0001fdf8 /system/lib/libc.so (syscall+40)
10-05 08:35:11.736 1717 1717 F DEBUG : #02 pc 00022ed3 /system/lib/libc.so (abort+115)
10-05 08:35:11.736 1717 1717 F DEBUG : #03 pc 00006f85 /system/lib/libbase.so (android::base::DefaultAborter(char const)+37)
10-05 08:35:11.736 1717 1717 F DEBUG : #04 pc 00008433 /system/lib/libbase.so (_ZNSt3__110__function6__funcIPFvPKcENS_9allocatorIS5_EES4_EclEOS3_+35)
10-05 08:35:11.736 1717 1717 F DEBUG : #05 pc 00007ccc /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+828)
10-05 08:35:11.736 1717 1717 F DEBUG : #06 pc 000083d2 /system/lib/libhidlbase.so (android::hardware::details::return_status::~return_status()+290)
10-05 08:35:11.736 1717 1717 F DEBUG : #07 pc 0004f386 /system/lib/libsurfaceflinger.so (android::Hwc2::impl::Composer::getActiveConfig(unsigned long long, unsigned int)+118)
10-05 08:35:11.736 1717 1717 F DEBUG : #08 pc 0005b1e4 /system/lib/libsurfaceflinger.so (HWC2::Display::getActiveConfigIndex(int) const+68)
10-05 08:35:11.736 1717 1717 F DEBUG : #09 pc 00062424 /system/lib/libsurfaceflinger.so (android::HWComposer::getActiveConfigIndex(int) const+100)
10-05 08:35:11.736 1717 1717 F DEBUG : #10 pc 000a04a4 /system/lib/libsurfaceflinger.so (android::SurfaceFlinger::processDisplayChangesLocked()+4884)
10-05 08:35:11.736 1717 1717 F DEBUG : #11 pc 00096e79 /system/lib/libsurfaceflinger.so (android::SurfaceFlinger::processDisplayHotplugEventsLocked()+985)
10-05 08:35:11.736 1717 1717 F DEBUG : #12 pc 000991f7 /system/lib/libsurfaceflinger.so (android::SurfaceFlinger::onHotplugReceived(int, unsigned long long, HWC2::Connection)+471)
10-05 08:35:11.736 1717 1717 F DEBUG : #13 pc 000992c0 /system/lib/libsurfaceflinger.so (non-virtual thunk to android::SurfaceFlinger::onHotplugReceived(int, unsigned long long,
HWC2::Connection)+48)
10-05 08:35:11.736 1717 1717 F DEBUG : #14 pc 0005e710 /system/lib/libsurfaceflinger.so
(_ZN4HWC212_GLOBAL__N_122ComposerCallbackBridge9onHotplugEyN7android8hardware8graphics8composer4V2_117IComposerCallback10ConnectionE$9c4dd39c938b72eb758b012354254820+48)
10-05 08:35:11.736 1717 1717 F DEBUG : #15 pc 0001f2b2 /system/lib/android.hardware.graphics.[email protected]
(android::hardware::graphics::composer::V2_1::BnHwComposerCallback::_hidl_onHotplug(android::hidl::base::V1_0::BnHwBase, android::hardware::Parcel const&, android::hardware::Parcel,
std::__1::function
(unsigned int, android::hardware::Parcel const&, android::hardware::Parcel, unsigned int, std::__1::function
10-05 08:35:11.736 1717 1717 F DEBUG : #18 pc 0001d657 /system/lib/libhwbinder.so (android::hardware::IPCThreadState::waitForResponse(android::hardware::Parcel, int*)+423)
10-05 08:35:11.736 1717 1717 F DEBUG : #19 pc 0001c041 /system/lib/libhwbinder.so (android::hardware::BpHwBinder::transact(unsigned int, android::hardware::Parcel const&,
android::hardware::Parcel*, unsigned int, std::__1::function
(android::hardware::graphics::composer::V2_1::BpHwComposerClient::_hidl_registerCallback(android::hardware::IInterface, android::hardware::details::HidlInstrumentor,
android::sp
10-05 08:35:11.737 1717 1717 F DEBUG : #21 pc 00029fd2 /system/lib/android.hardware.graphics.[email protected]
(android::hardware::graphics::composer::V2_1::BpHwComposerClient::registerCallback(android::sp
10-05 08:35:11.737 1717 1717 F DEBUG : #22 pc 0004e17b /system/lib/libsurfaceflinger.so (android::Hwc2::impl::Composer::registerCallback
(android::sp
10-05 08:35:11.737 1717 1717 F DEBUG : #23 pc 000594f9 /system/lib/libsurfaceflinger.so (HWC2::Device::registerCallback(HWC2::ComposerCallback, int)+217)
10-05 08:35:11.737 1717 1717 F DEBUG : #24 pc 00060bf8 /system/lib/libsurfaceflinger.so (android::HWComposer::registerCallback(HWC2::ComposerCallback, int)+40)
10-05 08:35:11.737 1717 1717 F DEBUG : #25 pc 00095efa /system/lib/libsurfaceflinger.so (android::SurfaceFlinger::init()+1418)
10-05 08:35:11.737 1717 1717 F DEBUG : #26 pc 000025ba /system/bin/surfaceflinger (main+458)
10-05 08:35:11.737 1717 1717 F DEBUG : #27 pc 000c0f54 /system/lib/libc.so (__libc_init+100)
10-05 08:35:16.594 1826 1826 I wificond: wificond is starting up...
I tried to run Detox with RN57 on its test project on both platforms, on macOS Mojave, and everything seems to work.
Is there a way for you to provide a demo project which recreates this issue ?
As per@ noomorph suggestion for crash, after reinstalling the whole code, its working fine and able to run the test.
I am not able to build using detox commands getting null pointer exception
@PSG2019 What exactly did you reinstall? I got the same issue and tried re-adding detox to the project mutliple times, but it won't work.
@boerdjamin My issue resolved due to configuration issues for android. I don't have the exact reason of not working detox code .
The issue seems resolved?
Most helpful comment
I tried to run Detox with RN57 on its test project on both platforms, on macOS Mojave, and everything seems to work.
Is there a way for you to provide a demo project which recreates this issue ?