-
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
Detox can't seem to tell when the app is ready on Android #3650
Comments
Same for me and I cannot explain why it freezes on My apk is built using Expo EAS. It's a local development build and in my Jest I followed the E2E guide for Expo and there is a warning at last step (when using development build) that this might not work properly on Android ^^ I figured out this issue using Full code of my import { ChildProcess, exec, spawn } from 'child_process'
import { device } from 'detox'
import { main } from '../package.json'
let client: ChildProcess | null = null
beforeAll(async () => {
runExpoDevClient()
await openAppForDebugBuild(process.env.DETOX_CONFIGURATION)
await waitForExpoDevClient()
})
afterAll(async () => {
// kill expo dev server (default port is 8081)
// not found for now a better way to do this ^^
exec('kill -9 $(lsof -t -i:8081)')
})
const openAppForDebugBuild = async platform => {
// Android and iOS don't work the same
// for Android, we have to launch app in one step using url parameter
// for iOS, we have to do this in two steps : launch app then open url
if (platform === 'ios') {
await device.launchApp({
newInstance: true,
})
await device.openURL({
url: getDeepLinkUrl(getDevLauncherPackagerUrl(platform)),
})
} else {
await device.launchApp({
newInstance: true,
url: getDeepLinkUrl(getDevLauncherPackagerUrl(platform)),
})
}
}
// /!\ you have to update "your-app" with your app scheme
const getDeepLinkUrl = url =>
`exp+your-app://expo-development-client/?url=${encodeURIComponent(
url
)}`
const getDevLauncherPackagerUrl = platform => {
// host is different for Android emulator
const host = platform === 'ios' ? 'localhost' : '10.0.2.2'
return `http://${host}:8081/${main}.bundle?platform=${platform}&dev=true&minify=false&disableOnboarding=1`
}
const runExpoDevClient = () => {
client = spawn('expo', ['start', '--dev-client'])
}
// I check with a regexp end of bundling
const waitForExpoDevClient = () => {
return new Promise((resolve, reject) => {
client?.stdout?.on('data', data => {
if (data && /(ios|android) Bundling complete/gi.test(`${data}`)) {
resolve(null)
}
})
client?.stderr?.on('data', data => {
reject(`stderr: ${data}`)
})
client?.on('close', code => {
reject(`child process exited with code ${code}`)
})
})
} Finally, I think it's because of Expo launcher screen. It runs before our app and Detox is lost. Good luck :) |
+1 having this issue, but i dont think we use expo... |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions! For more information on bots in this repository, read this discussion. |
The issue has been closed for inactivity. |
What happened?
I wrote a basic smoke test to make sure my app (an ejected Expo app that still uses it for certain build features) opens and a user can log in (among other tests). These all work fine in the iOS flow, while, on Android, the app does get properly installed and even started up, but Detox seems to hang on
launchApp
and eventually times out, seemingly on:What was the expected behaviour?
Android tests should also work and Detox should not hang
Was it tested on latest Detox?
Did your test throw out a timeout?
Help us reproduce this issue!
Unable to get the DetoxTemplate app to run in debug mode on Android right now, so unable to repro w/ the template: wix-incubator/DetoxTemplate#3
In what environment did this happen?
Detox version: 19.12.6
React Native version: 0.69.6
Node version: 16.14.2
Device model: Pixel 5
Android version: API 31
Test-runner (select one): jest-circus
Detox logs
Detox logs
Device logs
Device logs
device.log
More data, please!
smoke.e2e.ts
actions.ts
Build command maps to:
cd android && ENVFILE=.env.development IS_TEST=true ./gradlew assembleDevelopmentDebug assembleDevelopmentDebugAndroidTest -DtestBuildType=debug && cd ..
You can see here that running the test does successfully install and launch the app, but nothing beyond that:
Screen.Recording.2022-10-25.at.23.40.09.mov
The text was updated successfully, but these errors were encountered: