Expo集成Detox执行测试报错:Failed to execute the current status query
问题:Expo集成Detox测试时卡在
[APP_STATUS] Failed to execute the current status query错误 运行Detox测试时出现以下错误:
detox[3338] DEBUG: [APP_STATUS] Failed to execute the current status query.
测试文件firstTest.e2e.ts代码:
const { reloadApp } = require('detox-expo-helpers'); describe('Example', () => { beforeAll(async () => { await reloadApp({ permissions: { location: 'always', userTracking: 'YES' } }) }); it('test', async () => { await expect(element(by.id('settings'))).toBeVisible() await element(by.id('settings')).tap() console.log('success') }) })
操作步骤:
- 执行
yarn expo start --ios启动Expo服务 - 执行
yarn detox test -c ios --loglevel trace运行测试
应用可正常安装加载,但卡在上述错误。
可能的解决方案
检查版本兼容性
确保detox、detox-expo-helpers与当前Expo SDK版本匹配。运行npm ls detox detox-expo-helpers expo查看版本,确认符合官方兼容要求。让Detox自动管理Expo服务
无需手动启动Expo服务,关闭已启动的yarn expo start --ios进程,直接执行yarn detox test -c ios --loglevel trace,由Detox自动启动Expo服务并完成测试流程。简化
reloadApp配置
暂时移除权限配置,先测试基础流程:await reloadApp();若测试正常,再逐步添加权限参数,排查是否为特定权限配置导致的异常。
验证测试ID配置
确认应用中目标元素已正确设置testID="settings",比如:<TouchableOpacity testID="settings"> {/* 组件内容 */} </TouchableOpacity>清理缓存并重新构建
- 清理Expo缓存:
yarn expo r -c - 清理Detox构建缓存:
yarn detox clean - 重新构建测试包:
yarn detox build -c ios - 再次运行测试命令
- 清理Expo缓存:
内容的提问来源于stack exchange,提问作者Antoni
相关产品推荐
相关产品推荐

