当我尝试在 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/