You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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')
  })
})

操作步骤:

  1. 执行yarn expo start --ios启动Expo服务
  2. 执行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>
    
  • 清理缓存并重新构建

    1. 清理Expo缓存:yarn expo r -c
    2. 清理Detox构建缓存:yarn detox clean
    3. 重新构建测试包:yarn detox build -c ios
    4. 再次运行测试命令

内容的提问来源于stack exchange,提问作者Antoni

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 19:15:51