Skip to content
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

Detox test doesn't run on android #1508

Closed
1 task done
MuhmdRaouf opened this issue Jul 5, 2019 · 1 comment
Closed
1 task done

Detox test doesn't run on android #1508

MuhmdRaouf opened this issue Jul 5, 2019 · 1 comment

Comments

@MuhmdRaouf
Copy link

Describe the bug
I am starting new app fro scratch, and i am trying to setup detox for the app
and it runs on the ios fine, but when it comes to android it only open the emulator and nothing else but that, if i closed the test and start it again it only push the apk and nothing else happens and the test fails.
To Reproduce

  • I have tested this issue on the latest Detox release and it still reproduces

and those are my setting for the android part.

"e2e:android-build": "detox build --configuration android.emu.debug",
"e2e:android-test": "detox test --loglevel trace --configuration android.emu.debug --record-logs all --take-screenshots all --record-videos failing --loglevel verbose",

"android.emu.debug": {
        "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
        "build": "cd android && ./gradlew clean assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
        "type": "android.emulator",
        "name": "DETOX_EMULATOR"
      },

and here's the test, a hello world test:

describe('Example', () => {
	beforeEach(async () => {
		await device.reloadReactNative();
	});

	it('should have welcome screen', async () => {
		await expect(element(by.id('header'))).toBeVisible();
		await expect(element(by.text('Welcome to React'))).toBeVisible();
	});
});

Expected behavior
the emulator open and open the application and assert there's a 'Welcome to React' msg.

Environment (please complete the following information):

  • Detox: 13.0.2
  • React Native: 0.60.0
  • Node: 10.16.0
  • OS: macOS Mojave 10.14.5

Device and Verbose Detox Logs

> [email protected] e2e:android-test /Users/snowflake/SnowflakeProjects/iknewit-mobile
> detox test --loglevel trace --configuration android.emu.debug --record-logs all --take-screenshots all --record-videos failing --loglevel verbose

detox[80312] INFO:  [test.js] configuration="android.emu.debug" loglevel="verbose" artifactsLocation="artifacts/android.emu.debug.2019-07-05 22-03-41Z" recordLogs="all" takeScreenshots="all" recordVideos="failing" recordPerformance="none" reportSpecs=true node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:ios:).)*$' "e2e"
detox[80315] INFO:  [DetoxServer.js] server listening on localhost:62814...
detox[80315] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:62814
detox[80315] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=9c8673ad-28f4-5080-9e62-683a8e838c62
detox[80315] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=9c8673ad-28f4-5080-9e62-683a8e838c62
detox[80315] DEBUG: [exec.js/EXEC_CMD, #0] /Users/snowflake/Library/Android/sdk/emulator/emulator -list-avds --verbose
detox[80315] DEBUG: [exec.js/EXEC_CMD, #1] /Users/snowflake/Library/Android/sdk/platform-tools/adb  devices
detox[80315] DEBUG: [exec.js/EXEC_SUCCESS, #1] List of devices attached


detox[80315] DEBUG: [Emulator.js/SPAWN_CMD] /Users/snowflake/Library/Android/sdk/emulator/emulator -verbose -no-audio @DETOX_EMULATOR
Example: should have welcome screen
Example: should have welcome screen [FAIL]

FAIL e2e/firstTest.spec.js (121.587s)
  Example
    ✕ should have welcome screen (9ms)

  ● Example › should have welcome screen

    Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.

      at mapper (../node_modules/jest-jasmine2/build/queueRunner.js:25:45)

  ● 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 device (firstTest.spec.js:3:9)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (../node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at invoke (../node_modules/regenerator-runtime/runtime.js:135:20)
      at ../node_modules/regenerator-runtime/runtime.js:170:11
      at callInvokeWithMethodAndArg (../node_modules/regenerator-runtime/runtime.js:169:16)
      at AsyncIterator.enqueue (../node_modules/regenerator-runtime/runtime.js:192:13)
      at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at Object.<anonymous>.exports.async (../node_modules/regenerator-runtime/runtime.js:216:14)
      at Object._callee (firstTest.spec.js:2:13)

  ● Example › should have welcome screen

    ReferenceError: element is not defined

      4 |       });
      5 | 
    > 6 |       it('should have welcome screen', async () => {
        |                                        ^
      7 |               await expect(element(by.id('header'))).toBeVisible();
      8 |               await expect(element(by.text('Welcome to React'))).toBeVisible();
      9 |       });

      at _callee2$ (firstTest.spec.js:6:35)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (../node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at invoke (../node_modules/regenerator-runtime/runtime.js:135:20)
      at ../node_modules/regenerator-runtime/runtime.js:170:11
      at callInvokeWithMethodAndArg (../node_modules/regenerator-runtime/runtime.js:169:16)
      at AsyncIterator.enqueue (../node_modules/regenerator-runtime/runtime.js:192:13)
      at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at Object.<anonymous>.exports.async (../node_modules/regenerator-runtime/runtime.js:216:14)
      at Object._callee2 (firstTest.spec.js:6:35)

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

and if i have run it for the second time it only install the application but also wont work giving the following log :


> [email protected] e2e:android-test /Users/snowflake/SnowflakeProjects/iknewit-mobile
> detox test --loglevel trace --configuration android.emu.debug --record-logs all --take-screenshots all --record-videos failing --loglevel verbose

detox[80523] INFO:  [test.js] �[32mconfiguration="android.emu.debug" loglevel="verbose" artifactsLocation="artifacts/android.emu.debug.2019-07-05 22-08-27Z" recordLogs="all" takeScreenshots="all" recordVideos="failing" recordPerformance="none" reportSpecs=true node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:ios:).)*$' "e2e"�[39m
detox[80524] INFO:  [DetoxServer.js] �[32mserver listening on localhost:63644...�[39m
detox[80524] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] �[36mopened web socket to: ws://localhost:63644�[39m
detox[80524] DEBUG: [DetoxServer.js/LOGIN] �[36mrole=tester, sessionId=8153b8cc-f41d-dfa7-326d-3eb1727c6ddc�[39m
detox[80524] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] �[36mrole=tester, sessionId=8153b8cc-f41d-dfa7-326d-3eb1727c6ddc�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #0] �[36m/Users/snowflake/Library/Android/sdk/emulator/emulator -list-avds --verbose�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #1] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb  devices�[39m
detox[80524] DEBUG: [exec.js/EXEC_SUCCESS, #1] �[36mList of devices attached�[39m
�[36memulator-5554	device�[39m

�[36m�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #2] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "getprop dev.bootcomplete"�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #3] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "getprop ro.build.version.sdk"�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #4] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "dumpsys power | grep \"^[ ]*m[UW].*=\""�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #5] �[36m/Users/snowflake/Library/Android/sdk/build-tools/29.0.0-rc2/aapt dump badging "/Users/snowflake/SnowflakeProjects/iknewit-mobile/android/app/build/outputs/apk/debug/app-debug.apk" | grep -e "package: name="�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #6] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "pm list packages com.iknewit"�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #7] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "pm list packages com.iknewit.test"�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #8] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -r -g -t "/Users/snowflake/SnowflakeProjects/iknewit-mobile/android/app/build/outputs/apk/debug/app-debug.apk"�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #9] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -r -g -t "/Users/snowflake/SnowflakeProjects/iknewit-mobile/android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk"�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #10] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "am force-stop com.iknewit"�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #11] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "date +\"%m-%d %T.000\""�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #12] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "pm list instrumentation"�[39m
detox[80524] DEBUG: [exec.js/SPAWN_CMD, #13] �[36m[pid=80543] /Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:63644 -e detoxSessionId 8153b8cc-f41d-dfa7-326d-3eb1727c6ddc -e debug ZmFsc2U= com.iknewit.test/androidx.test.runner.AndroidJUnitRunner�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #14] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "ps | grep \"com\.iknewit$\""�[39m
detox[80524] DEBUG: [exec.js/SPAWN_CMD, #15] �[36m[pid=80545] /Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "logcat -T \"07-06 00:08:31.000\" --pid=5200 -f /sdcard/0830157_0.log"�[39m
detox[80524] DEBUG: [DetoxServer.js/CANNOT_FORWARD] �[36mrole=testee not connected, cannot fw action (sessionId=8153b8cc-f41d-dfa7-326d-3eb1727c6ddc)�[39m
detox[80524] DEBUG: [exec.js/EXEC_CMD, #16] �[36m/Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell du /sdcard/0830157_0.log�[39m
detox[80524] DEBUG: [exec.js/KILL] �[36msending SIGINT to [pid = 80543]: /Users/snowflake/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:63644 -e detoxSessionId 8153b8cc-f41d-dfa7-326d-3eb1727c6ddc -e debug ZmFsc2U= com.iknewit.test/androidx.test.runner.AndroidJUnitRunner�[39m
Example: should have welcome screen
Example: should have welcome screen [FAIL]


FAIL e2e/firstTest.spec.js (121.556s)
  Example
    ✕ should have welcome screen (12ms)

  ● Example › should have welcome screen

    Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.

      at mapper (../node_modules/jest-jasmine2/build/queueRunner.js:25:45)

  ● 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 device (firstTest.spec.js:3:9)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (../node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at invoke (../node_modules/regenerator-runtime/runtime.js:135:20)
      at ../node_modules/regenerator-runtime/runtime.js:170:11
      at callInvokeWithMethodAndArg (../node_modules/regenerator-runtime/runtime.js:169:16)
      at AsyncIterator.enqueue (../node_modules/regenerator-runtime/runtime.js:192:13)
      at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at Object.<anonymous>.exports.async (../node_modules/regenerator-runtime/runtime.js:216:14)
      at Object._callee (firstTest.spec.js:2:13)

  ● Example › should have welcome screen

    ReferenceError: element is not defined

      4 |       });
      5 | 
    > 6 |       it('should have welcome screen', async () => {
        |                                        ^
      7 |               await expect(element(by.id('header'))).toBeVisible();
      8 |               await expect(element(by.text('Welcome to React'))).toBeVisible();
      9 |       });

      at _callee2$ (firstTest.spec.js:6:35)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (../node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at invoke (../node_modules/regenerator-runtime/runtime.js:135:20)
      at ../node_modules/regenerator-runtime/runtime.js:170:11
      at callInvokeWithMethodAndArg (../node_modules/regenerator-runtime/runtime.js:169:16)
      at AsyncIterator.enqueue (../node_modules/regenerator-runtime/runtime.js:192:13)
      at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at Object.<anonymous>.exports.async (../node_modules/regenerator-runtime/runtime.js:216:14)
      at Object._callee2 (firstTest.spec.js:6:35)

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
@support
Copy link

support bot commented Jul 10, 2019

We use the issue tracker exclusively for bug reports and feature requests. This issue appears to be a general usage or support question. Instead, please ask a question on Stack Overflow with the detox tag.

Feel free to post your Stack Overflow question here for more visility. We'll take a look at it.

For more information on bots in this reporsitory, read this discussion.

@support support bot closed this as completed Jul 10, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants