react-native - Bitrise + Detox + React-native - Hello World 示例挂在 detox.init 上
问题描述
我正在尝试使用 Detox 设置react-native “Hello World”应用程序并在 Bitrise.io 上运行。我浏览了 react-native-cli 入门指南,并尝试在 Bitrise 上使用 Detox + Jest 运行最简单的排毒测试。
我遇到的具体错误是未定义device
和全局变量(请参阅日志或下面的链接)。element
从我到目前为止的研究来看,这是由于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
提前致谢!
比特上升错误日志
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 () => {
比特升.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
解决方案
不幸的是,这是一个非常普遍的错误,可能是由多种原因引起的(不兼容的 OS/jest + detox 版本/node + detox 版本等)。
如果您使用的是 MacOS,您可以选择通过屏幕共享连接来检查 Bitrise 的 VM 中出了什么问题:我建议while someFileDoesntExist
在您当前的工作流程中添加一个(在没有中止按钮的情况下自然停止迭代)包安装步骤(节点、排毒、开玩笑等),然后检查它是否与您在本地运行的相同。
如果不是这种情况,请检查 VM 是否运行相同的模拟器——手机型号 && 操作系统版本;如果不是,那么您可以在排毒配置中指定模拟器和操作系统版本。
如果那也不起作用,我不确定它可能是什么:(
推荐阅读
- python - 了解 gensim Word2Vec most_similar 结果为 3 个词
- python-3.x - 变量“foo_class”作为类型无效,但为什么呢?
- java - 如何使用 Java 在 Android 中获取颜色的 R、G、B 值?
- selenium-webdriver - 量角器 - seleniumAddress 和 directConnect 有什么区别
- r - 将 ggplot2 对象添加到绘图列表中
- google-apps-script - 对于 Google 表格中的每个循环?以 VBA 为例
- ios - 如何使用 poptoviewcontroller 返回到以前的控制器
- php - 检测到 Symfony4 错误 php 版本的 Laravel\Vagrant Homestead
- java - Spring JPA 用 Oher 列连接两个表
- javascript - 错误“0: 'Open' is not defined”和“SCRIPT1005: SCRIPT1005: Expected '('” 如何修复这些错误?