【问题标题】:Bitrise + Detox + React-native - Hello World Example hangs on detox.initBitrise + Detox + React-native - Hello World 示例挂在 detox.init 上
【发布时间】:2020-03-07 11:52:34
【问题描述】:

我正在尝试使用 Detox 设置 react-native "Hello World" app 并在 Bitrise.io 上运行。我浏览了 react-native-cli 入门指南,并尝试在 Bitrise 上使用 Detox + Jest 运行最简单的排毒测试。

我遇到的具体错误是未定义 deviceelement 全局变量(请参阅日志或下面的链接)。从我目前的研究来看,这是由detox.init 没有完成造成的。

是否有一些我缺少的 Bitrise 基本配置? detox test 命令在本地运行对我来说很好。

我使用的是免费的 Bitrise 帐户,该项目是公开的。你可以在这里看到一个失败的构建:https://app.bitrise.io/build/e7926ddfc759288f#?tab=log

回购也是公开的:https://github.com/jamesopti/react-native-test/blob/add_detox/AwesomeProject/e2e/firstTest.spec.js

提前致谢!

Bitrise 错误日志

Example: should have welcome screen
Example: should have welcome screen [FAIL]
FAIL e2e/firstTest.spec.js (122.008s)
  Example
    ✕ should have welcome screen (8ms)
  ● Example › should have welcome screen
    Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.
      at mapper (../node_modules/jest-jasmine2/build/queueRunner.js:25:45)
  ● Example › should have welcome screen
    ReferenceError: device is not defined
      1 | describe('Example', () => {
      2 |   beforeEach(async () => {
    > 3 |     await device.reloadReactNative();
        |           ^
      4 |   });
      5 | 
      6 |   it('should have welcome screen', async () => {

bitrise.yml

---
format_version: '8'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: react-native
trigger_map:
- push_branch: "*"
  workflow: primary
- pull_request_source_branch: "*"
  workflow: primary
workflows:
  deploy:
    description: "## ..."
    steps:
    - activate-ssh-key@4.0.3:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.17: {}
    - script@1.1.5:
        title: Do anything with Script step
    - yarn@0.1.0:
        inputs:
        - workdir: AwesomeProject
        - command: install
    - install-missing-android-tools@2.3.7:
        inputs:
        - gradlew_path: "$PROJECT_LOCATION/gradlew"
    - android-build@0.10.0:
        inputs:
        - project_location: "$PROJECT_LOCATION"
    - certificate-and-profile-installer@1.10.1: {}
    - xcode-archive@2.7.0:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
        - scheme: "$BITRISE_SCHEME"
        - export_method: "$BITRISE_EXPORT_METHOD"
        - configuration: Release
    - deploy-to-bitrise-io@1.9.2: {}
  primary:
    steps:
    - activate-ssh-key@4.0.3:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.17: {}
    - yarn@0.1.0:
        inputs:
        - workdir: AwesomeProject
        - command: install
        title: Yarn Install
    - yarn@0.1.0:
        inputs:
        - workdir: AwesomeProject
        - command: test
        title: Unit tests
    after_run:
    - detox
  detox:
    steps:
    - cocoapods-install@1.9.1:
        inputs:
        - source_root_path: "$BITRISE_SOURCE_DIR/AwesomeProject/ios"
    - npm@1.1.0:
        title: Install Global
        inputs:
        - workdir: "$BITRISE_SOURCE_DIR/AwesomeProject"
        - command: install -g detox-cli react-native-cli
    - script@1.1.5:
        inputs:
        - working_dir: "$BITRISE_SOURCE_DIR/AwesomeProject"
        - content: |-
            #!/usr/bin/env bash

            brew tap facebook/fb
            export CODE_SIGNING_REQUIRED=NO
            brew install fbsimctl
            brew tap wix/brew
            brew install applesimutils --HEAD
        title: Install detox utils
    - script@1.1.5:
        inputs:
        - working_dir: "$BITRISE_SOURCE_DIR/AwesomeProject"
        - content: |-
            #!/usr/bin/env bash

            detox build --configuration ios.sim.debug
        title: Detox Build
    - script@1.1.5:
        inputs:
        - working_dir: "$BITRISE_SOURCE_DIR/AwesomeProject"
        - content: |-
            #!/usr/bin/env bash

            detox test --configuration ios.sim.debug --cleanup
        title: Detox Test
app:
  envs:
  - opts:
      is_expand: false
    PROJECT_LOCATION: AwesomeProject/android
  - opts:
      is_expand: false
    MODULE: app
  - opts:
      is_expand: false
    VARIANT: ''
  - opts:
      is_expand: false
    BITRISE_PROJECT_PATH: AwesomeProject/ios/AwesomeProject.xcworkspace
  - opts:
      is_expand: false
    BITRISE_SCHEME: AwesomeProject
  - opts:
      is_expand: false
    BITRISE_EXPORT_METHOD: ad-hoc
meta:
  bitrise.io:
    machine_type: elite

【问题讨论】:

    标签: react-native jestjs detox bitrise


    【解决方案1】:

    不幸的是,这是一个非常普遍的错误,可能由多种原因引起(不兼容的 OS/jest + detox 版本/node + detox 版本等)。

    如果您使用的是 MacOS,您可以选择通过Screen Sharing 连接来检查 Bitrise 的 VM 中出了什么问题:我建议添加一个 while someFileDoesntExist(在没有中止按钮的情况下自然停止迭代) 在软件包安装步骤(节点、排毒、开玩笑等)之后的当前工作流程中,然后检查它是否与您在本地运行的相同。

    如果不是这样,请检查虚拟机是否运行相同的模拟器 -- 手机型号 && 操作系统版本;如果不是,那么您可以在 detox 配置中指定模拟器和操作系统版本。

    如果这也不起作用,我不确定它会是什么:(

    【讨论】:

      猜你喜欢
      • 2021-05-10
      • 2018-07-02
      • 2012-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-26
      相关资源
      最近更新 更多