gpt4 book ai didi

react-native - Bitrise + Detox + React-native - Hello World 示例卡在 detox.init 上

转载 作者:行者123 更新时间:2023-12-05 07:17:30 32 4
gpt4 key购买 nike

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

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

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

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

repo 也是公开的: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

最佳答案

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

如果您使用的是 MacOS,您可以选择通过 Screen Sharing 连接来检查 Bitrise 的 VM 中出了什么问题。 :我建议在包安装步骤(node、detox、jest 等)之后在当前工作流程中添加一个 while someFileDoesntExist(无需中止按钮自然停止迭代),然后检查它是否相同您在本地运行的一个。

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

如果那也不起作用,我不确定它可能是什么 :(

关于react-native - Bitrise + Detox + React-native - Hello World 示例卡在 detox.init 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58807362/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com