expo / eas-tests-example

Demo of running E2E tests on EAS Build
33 stars 2 forks source link

Android not working on development builds #4

Closed Aiden-recovery closed 1 year ago

Aiden-recovery commented 2 years ago

i have one question. does 'detox:android:debug:test' script work correctly? i think it is hanging expo intro screen :(

when i run 'detox:android:debug:test' after 'detox:android:debug:build' it couldn't run with this error logs

thanks for your effort

21:12:28.657 detox[59778] INFO:  Home screen is assigned to emulator-5554 (Pixel_4_API_31)
21:12:28.657 detox[59778] INFO:  Home screen: "Click me" button should be visible
21:14:28.681 detox[59778] WARN:  [PENDING_REQUESTS] The app has not responded to the network requests below:
  (id = 1) currentStatus: {}
  (id = -1000) isReady: {}

That might be the reason why the test "Home screen "Click me" button should be visible" has timed out.

21:14:28.682 detox[59778] INFO:  Home screen: "Click me" button should be visible [FAIL]
21:14:28.691 detox[59778] INFO:  Home screen: shows "Hi!" after tapping "Click me"
21:14:28.698 detox[59778] WARN:  at node_modules/detox/src/devices/runtime/drivers/android/AndroidDriver.js:156:17 
 An error occurred while waiting for the app to become ready. Waiting for disconnection... Error:
 DetoxRuntimeError: Failed to run application on the device

HINT: Most likely, your tests have timed out and called detox.cleanup() while it was waiting for "ready" message (over WebSocket) from the instrumentation process.
    at MonitoredInstrumentation._getInstrumentationCrashError (/Users/.../eas-tests-example/node_modules/detox/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js:72:12)
    at MonitoredInstrumentation._rejectPendingCrashPromise (/Users/.../eas-tests-example/node_modules/detox/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js:60:37)
    at MonitoredInstrumentation._onInstrumentationTerminated (/Users/.../eas-tests-example/node_modules/detox/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js:55:10)
    at Instrumentation._onTerminated (/Users/.../eas-tests-example/node_modules/detox/src/devices/common/drivers/android/tools/Instrumentation.js:54:18)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
21:14:28.752 detox[59778] WARN:  at node_modules/detox/src/devices/runtime/drivers/android/AndroidDriver.js:158:17 
 ...app disconnected.
21:16:28.699 detox[59778] WARN:  [PENDING_REQUESTS] The app has not responded to the network requests below:
  (id = 2) currentStatus: {}
  (id = -1000) isReady: {}

That might be the reason why the test "Home screen shows "Hi!" after tapping "Click me"" has timed out.

21:16:28.699 detox[59778] INFO:  Home screen: shows "Hi!" after tapping "Click me" [FAIL]

21:16:28.800 detox[59778] WARN:  at node_modules/detox/src/devices/runtime/drivers/android/AndroidDriver.js:156:17 
 An error occurred while waiting for the app to become ready. Waiting for disconnection... Error:
 DetoxRuntimeError: Failed to run application on the device

HINT: Most likely, your tests have timed out and called detox.cleanup() while it was waiting for "ready" message (over WebSocket) from the instrumentation process.
    at MonitoredInstrumentation._getInstrumentationCrashError (/Users/.../eas-tests-example/node_modules/detox/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js:72:12)
    at MonitoredInstrumentation._rejectPendingCrashPromise (/Users/.../eas-tests-.example/node_modules/detox/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js:60:37)
    at MonitoredInstrumentation._onInstrumentationTerminated (/Users/.../eas-tests-example/node_modules/detox/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js:55:10)
    at Instrumentation._onTerminated (/Users/.../eas-tests-example/node_modules/detox/src/devices/common/drivers/android/tools/Instrumentation.js:54:18)
21:16:28.800 detox[59778] WARN:  at node_modules/detox/src/devices/runtime/drivers/android/AndroidDriver.js:158:17 
 ...app disconnected.
 FAIL  e2e/tests/homeScreen.e2e.js (241.547 s)
  Home screen
    ✕ "Click me" button should be visible (120005 ms)
    ✕ shows "Hi!" after tapping "Click me" (120007 ms)

  ● Home screen › "Click me" button should be visible

    thrown: "Exceeded timeout of 120000 ms for a hook.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      2 |
      3 | describe('Home screen', () => {
    > 4 |   beforeEach(async () => {
        |   ^
      5 |     await device.launchApp({
      6 |       newInstance: true,
      7 |     });

      at beforeEach (tests/homeScreen.e2e.js:4:3)
      at Object.describe (tests/homeScreen.e2e.js:3:1)

  ● Home screen › shows "Hi!" after tapping "Click me"

    thrown: "Exceeded timeout of 120000 ms for a hook.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      2 |
      3 | describe('Home screen', () => {
    > 4 |   beforeEach(async () => {
        |   ^
      5 |     await device.launchApp({
      6 |       newInstance: true,
      7 |     });

      at beforeEach (tests/homeScreen.e2e.js:4:3)
      at Object.describe (tests/homeScreen.e2e.js:3:1)

21:16:29.051 detox[59777] ERROR: [cli.js] Command failed: jest --config e2e/config.json --testNamePattern '^((?!:ios:).)*$' e2e

Process finished with exit code 1
dsokal commented 2 years ago

Hey, Unfortunately, debug builds don't work with Android yet. This is something we are aware of and should address it soon. @douglowder should have more insight on this :)


This is also stated in our docs:

https://docs.expo.dev/build-reference/e2e-tests/#using-development-builds-to-speed-up-test

Screenshot 2022-10-18 at 14 27 19
mononoke-choi commented 2 years ago

oh, i missed important warning.. :( thanks your fast reply !

douglowder commented 2 years ago

@mononoke-choi the specific issue we are facing is that the Detox method device.openUrl() does not work on Android. We are trying out some different ideas for making this work, but have not yet found a reliable solution.

david-alza commented 2 years ago

@douglowder / @mononoke-choi we were able to get android debug tests working. You just need to call device.LaunchApp with the deep link URL constructed like the docs show (and then you can drop the openApp call).

Weirdly enough ios doesn't like it when you do that... and prefers separate calls. Thus our openAppForDebugBuild looks like this:

export async function launchAppForDebugBuild(platform) {
    // for debug builds ios only works if you launch the app first then open it with the deep link
    // android only works if you launch it directly with the deep link
    const deepLinkUrl = getDeepLinkUrl(getDevLauncherPackagerUrl(platform));
    if (platform === "ios") {
      await device.launchApp();
      await device.openURL({
        url: deepLinkUrl,
      });
    } else {
      await device.launchApp({
        url: deepLinkUrl,
      });
    }
}

There are two warnings thrown in android (at least for us) right after this:

 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.

We can probably just suppress these with logbox for now though.

jeremy-kunzhou commented 1 year ago

I got a trouble on testing this example for android in test_debug. During the test, I followed the following steps: 1 run yarn install to install dependences 2 run eas build -p android -e test_debug

After long waiting on the eas page, the test failed and got exactly the same error output which is posted by @Aiden-recovery

Any suggestion is welcome. @dsokal Thanks for your time and example.

tetsuchii commented 1 year ago

Hey! Did you find any solutions for the problem? @jeremy-kunzhou I got the same problem as you, and @Aiden-recovery. The error output is the exact same.

I hope somebody can help!