RN 0.77升级至0.79后Detox测试超时:等待应用就绪失败
React Native 0.79/0.78升级后Detox测试超时问题求助
我已经折腾这个问题好几天了:之前在RN 0.77版本下用Detox编写测试一切正常,但将应用升级至RN 0.79后,测试始终超时,报错信息如下:
An error occurred while waiting for the app to become ready. Waiting for disconnection... error: 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.
堆栈跟踪信息:
@Thread detox.primary(100): java.lang.RuntimeException: java.util.concurrent.ExecutionException: androidx.test.espresso.IdlingResourceTimeoutException: Wait for [com.wix.detox.reactnative.idlingresources.network.NetworkIdlingResource] to become idle timed out at androidx.test.espresso.Espresso.onIdle(Espresso.java:357) at com.wix.detox.TestEngineFacade.awaitIdle(TestEngineFacade.kt:12) at com.wix.detox.adapters.server.ReadyActionHandler.handle(DetoxActionHandlers.kt:25) at com.wix.detox.DetoxMain$setupActionHandlers$SynchronizedActionHandler.handle(DetoxMain.kt:76) at com.wix.detox.adapters.server.ActionsExecutor.executeAction$lambda$2$lambda$1(DetoxActionsDispatcher.kt:76) at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$GVbB7LHtBHxNHGbgYnHJ6YrwCqs(Unknown Source:0) at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at com.wix.detox.adapters.server.ActionsExecutor._init_$lambda$0(DetoxActionsDispatcher.kt:62) at com.wix.detox.adapters.server.ActionsExecutor.$r8$lambda$xlgL0CQim6vNM0wWEqM8JIDgZUE(Unknown Source:0) at com.wix.detox.adapters.server.ActionsExecutor$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0) at java.lang.Thread.run(Thread.java:1012)
我尝试过的操作:
- 将应用降级至官方支持的RN 0.78版本,问题依旧
- 注意到有针对RN 0.79的支持修改,尝试用patch-package应用修改但未成功
- 用相同版本的Detox(20.40.2)和RN(0.79.1)创建的小型测试项目运行完全正常
环境信息:
- RN 0.79.1
- Gradle 8.13
- 目标SDK 35
- 运行设备:搭载Android 14的三星Galaxy Tab Active5
补充说明:问题并非直接与Espresso相关,而是Detox(内部使用Espresso)未检测到应用已启动,导致测试无法开始,即使延长超时时间也无济于事。
项目package.json依赖信息:
"dependencies": { "@dylankenneally/react-native-ssh-sftp": "^1.5.20", "@react-native-async-storage/async-storage": "^2.1.0", "@react-native-community/datetimepicker": "^8.2.0", "@react-native-community/netinfo": "^11.4.1", "@react-native-vector-icons/material-design-icons": "^12.3.0", "@react-navigation/bottom-tabs": "^7.3.10", "@react-navigation/drawer": "^7.3.9", "@react-navigation/material-top-tabs": "^7.2.10", "@react-navigation/native": "^7.1.6", "@reduxjs/toolkit": "^2.6.1", "@sentry/react-native": "^6.10.0", "@shopify/flash-list": "^2.0.0-alpha.21", "axios": "^1.7.9", "base-64": "^1.0.0", "date-fns": "^4.1.0", "i18next": "^24.0.5", "i18next-xhr-backend": "^3.2.2", "intl": "^1.2.5", "intl-pluralrules": "^2.0.1", "jwt-decode": "^4.0.0", "lodash": "^4.17.21", "postinstall-postinstall": "^2.1.0", "react": "19.0.0", "react-dom": "^19.0.0", "react-i18next": "^15.1.1", "react-moment": "^1.1.3", "react-native": "^0.79.1", "react-native-autocomplete-dropdown": "^4.4.0", "react-native-blob-util": "^0.19.11", "react-native-device-info": "^14.0.1", "react-native-easy-grid": "^0.2.2", "react-native-exit-app": "^2.0.0", "react-native-gesture-handler": "^2.25.0", "react-native-gradle-plugin": "^0.71.19", "react-native-idle-timer": "^2.2.3", "react-native-localize": "^3.2.1", "react-native-logs": "^5.3.0", "react-native-material-menu": "^2.0.0", "react-native-network-logger": "^2.0.0", "react-native-ntp-client": "^1.0.3", "react-native-pager-view": "^6.7.1", "react-native-paper": "^5.13.2", "react-native-paper-dropdown": "^2.3.1", "react-native-reanimated": "^3.17.4", "react-native-safe-area-context": "^5.4.0", "react-native-screens": "^4.10.0", "react-native-svg": "^15.10.1", "react-native-table-component": "^1.2.2", "react-native-toast-message": "^2.2.1", "react-native-udp": "^4.1.7", "react-query": "^3.39.3", "react-redux": "^9.2.0", "react-use": "^17.6.0", "redux": "^5.0.1", "redux-persist": "^6.0.0", "redux-thunk": "^3.1.0", "rn-fetch-blob": "^0.12.0", "socket.io-client": "^4.8.1", "url-parse": "^1.5.10", "yup": "^1.5.0" }, "devDependencies": { "@babel/core": "^7.26.10", "@babel/eslint-parser": "^7.26.9", "@babel/preset-env": "^7.26.9", "@babel/runtime": "^7.27.0", "@eslint/js": "^9.32.0", "@react-native-community/cli": "18.0.0", "@react-native-community/cli-platform-android": "18.0.0", "@react-native/babel-preset": "^0.79.1", "@react-native/metro-config": "0.79.1", "@welldone-software/why-did-you-render": "^10.0.1", "eslint": "^9.32.0", "eslint-plugin-prettier": "^5.5.4", "eslint-config-prettier": "^10.1.8", "eslint-plugin-react": "^7.37.5", "globals": "^16.3.0", "patch-package": "^8.0.0", "prettier": "^3.6.2", "@types/jest": "^29.5.13", "@types/react": "^19.0.0", "@types/react-test-renderer": "^19.0.0", "detox": "20.40.2", "jest": "^29.7.0", "jest-circus": "^30.0.5", "react-test-renderer": "19.0.0", "typescript": "5.0.4", "node-opcua": "^2.156.0" }, "engines": { "node": ">=18 <21" }
有没有人遇到过类似问题?求提供解决思路,我已经研究这个问题超过一周了,非常感谢。
内容的提问来源于stack exchange,提问作者Manorka
相关产品推荐
相关产品推荐

