react-native - 在 Expo React Native 项目中使用 Detox 运行测试时出错

标签 react-native expo e2e-testing detox

当我尝试在 React Native Expo 项目中使用 detox 运行我的测试时,我收到以下错误:

detox[18834] WARN:  [Client.js/PENDING_REQUESTS] App has not responded to the network requests below:
  (id = -1000) isReady: {}

That might be the reason why the test "Login workflow should have login screen" has timed out.

detox[18834] INFO:  Login workflow: should have login screen [FAIL]

 FAIL  e2e/firstTest.e2e.js (137.697 s)
  Login workflow
    ✕ should have login screen (120015 ms)

  ● Login workflow › should have login screen

    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."

       7 |   });
       8 |
    >  9 |   it('should have login screen', async () => {
         |   ^
      10 |     await expect(element(by.id('loginFormTitle'))).toBeVisible()
      11 |   });
      12 |

      at firstTest.e2e.js:9:3
      at Object.<anonymous> (firstTest.e2e.js:8:1)

detox[18833] ERROR: [cli.js] Error: Command failed: node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:android:).)*$' --maxWorkers 1 e2e
我正在运行 iPhone 11 Pro 模拟器,并且 expo 应用程序已经在单独的服务器中运行。我也有Exponent.app在我的 /bin文件夹,这是我从世博会网站下载的。我的测试用例中的逻辑不需要任何超时,它只涉及一个简单的登录屏幕。
这个错误有什么解决办法吗?

最佳答案

我在使用最新版本的 Expo (v39) 时遇到了类似的问题。
问题似乎是 Detox 在运行测试之前等待应用程序就绪事件,但这不会被最新版本的 Expo SDK 触发。
我最终得到的解决方案是创建应用程序的独立版本并针对它运行 Detox。
我的 .detoxrc.json好像:

{
  ...,
  "configurations": {
    "ios": {
      "type": "ios.simulator",
      "build": "expo build:ios -t simulator",
      "binaryPath": "bin/myapp.app",                                                                                                            
    }
  }
}

关于react-native - 在 Expo React Native 项目中使用 Detox 运行测试时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63137314/

相关文章:

node.js - 进行端到端测试时如何正确运行我的应用程序?

testing - TestCafe - 如何通过 auth0 登录使用角色

ios - React Native网络请求在iPhone上失败但在iOS模拟器上成功

javascript - KeyboardAvoidingView 不适用于 Expo

javascript - 通过映射的 onPress 事件切换对象属性

react-native - 无法将现有的 React Native 转换为 Expo : error with nativeVersion. 主要

javascript - 'info' 和 'history' 在tensorflow.js的模型中未定义

javascript - Testcafe 客户端功能失败 "An error occurred in ClientFunction code: ReferenceError: _from2 is not defined"

android - Kotlin 多平台用于开发 Mobile SDK?

android - react native 生成​​签名 APK