【问题标题】:Detox tests are not finishing排毒测试未完成
【发布时间】:2018-04-20 03:25:08
【问题描述】:

我已经为 E2E 测试设置了 detox,并为持续集成设置了 Bitrise。

我已经设置了一个非常简单的初始测试套件,但由于某种原因,我的测试在完成后没有完成

init.js

require('babel-polyfill');
const detox = require('detox');
const config = require('../package.json').detox;

before(async () => {
  await detox.init(config);
});

after(async () => {
  await detox.cleanup();
});

firstTest.spec.js

describe('Example', () => {
  beforeEach(async () => {
    await device.reloadReactNative();
  });

  it('should have welcome screen', async () => {
    await expect(element(by.id('UniqueID'))).toBeVisible();
  });
})

工作流程段: (这只是一个脚本步骤

brew update

node -v

brew tap wix/brew

brew install wix/brew/applesimutils

npm install -g detox-cli

detox build --configuration ios.sim.release

(稍后将移植到 .yml 文件)

package.json - 省略所有不必要的东西。

"detox": {
        "configurations": {
            "ios.sim.debug": {
                "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/AlarmApp.app",
                "build": "xcodebuild -project ios/AlarmApp.xcodeproj -scheme AlarmApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
                "type": "ios.simulator",
                "name": "iPhone 8"
            },
            "ios.sim.release": {
                "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/AlarmApp.app",
                "build": "xcodebuild -project ios/AlarmApp.xcodeproj -scheme AlarmApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
                "type": "ios.simulator",
                "name": "iPhone 8"
            }
        }
    }

Bitrise 成功执行了我的测试,我可以在本地机器上运行它们,因此问题出在 Detox 上。

测试会通过,但它只是挂起。

detox.cleanup() 函数被调用,因为我可以在日志文件中看到它:

2017-11-07 16:23:02.802 AlarmApp[15771:1271275] Crash handler setup started.
2017-11-07 16:23:02.805 AlarmApp[15771:1271275] Crash handler setup completed.
2017-11-07 16:23:02.805 AlarmApp[15771:1271275] Enabling accessibility for automation on Simulator.
2017-11-07 16:23:04.427 AlarmApp[15771:1271275] ☣️ DETOX:: Detox Action Sent: login
2017-11-07 16:23:04.714 AlarmApp[15771:1271275] ☣️ DETOX:: Detox Action Received: loginSuccess
2017-11-07 16:23:04.795 AlarmApp[15771:1271275] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.AccessibilityManagerQueue>
2017-11-07 16:23:04.821 AlarmApp[15771:1271275] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.PlatformConstantsQueue>
2017-11-07 16:23:05.276 AlarmApp[15771:1271275] ☣️ DETOX:: Detox Action Sent: ready
2017-11-07 16:23:05.287 AlarmApp[15771:1271275] ☣️ DETOX:: Detox Action Received: reactNativeReload
2017-11-07 16:23:05.293 AlarmApp[15771:1271275] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.AccessibilityManagerQueue>
2017-11-07 16:23:05.293 AlarmApp[15771:1271275] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.PlatformConstantsQueue>
2017-11-07 16:23:05.402 AlarmApp[15771:1271275] ☣️ DETOX:: Detox Action Sent: ready
2017-11-07 16:23:05.409 AlarmApp[15771:1271275] ☣️ DETOX:: Detox Action Received: invoke
2017-11-07 16:23:05.836 AlarmApp[15771:1271275] ☣️ DETOX:: Detox Action Sent: invokeResult
2017-11-07 16:23:05.844 AlarmApp[15771:1271275] ☣️ DETOX:: Detox Action Received: cleanup
2017-11-07 16:23:05.845 AlarmApp[15771:1271275] ☣️ DETOX:: Detox Action Sent: cleanupDone

任何帮助将不胜感激。

【问题讨论】:

    标签: react-native bitrise detox


    【解决方案1】:

    来自 Bitrise 的维克托。

    我们的一位用户报告了同样的问题(虽然我不确定他们是否使用了 detox,但 React Native 肯定并且同样的“测试已完成但进程不存在”问题)。

    我试图获得尽可能多的信息,因为我们确实在临时虚拟机中使用它们进行了调试:

    谢谢,我想我找到了问题!我们的一些旧测试使用 react-native-test-renderer 而不是像新测试那样的酶。他们正在渲染一个带有循环动画的组件,这就是导致挂起的原因。一旦我切换到浅渲染,问题就解决了。感谢您的帮助!

    另外值得一提的是,当他们在项目中升级 React Native 版本时,问题就开始发生了

    我想在以前的 React Native 版本中,渲染器并没有运行子组件中的所有代码,但是发生了一些变化,现在它可以运行了。有问题的代码确实会无限循环,因此导致挂起也就不足为奇了。

    我希望这对 @Dan 有所帮助,如果它不只是让我知道或 ping 我们的支持;)

    【讨论】:

      猜你喜欢
      • 2020-03-16
      • 2021-11-08
      • 2018-04-30
      • 2019-06-23
      • 2018-06-28
      • 1970-01-01
      • 2018-05-13
      • 2019-07-19
      • 2014-05-01
      相关资源
      最近更新 更多