「React Native」UI自动化环境搭建(Android)

一、环境搭建

1.参考之前ios的环境搭建,先将公共的需要的环境安装好(detox:18.6.2, react native:0.61.5,react:16.9.0)
2.参考官方文档进行配置

https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md

3.配置package.json
   "apps": {
      "android.debug": {
        "type": "android.apk",
        "binaryPath": "android/app/build/outputs/apk/hcdtest/debug/app-hcdtest-debug.apk",
        "build": "cd android && ./gradlew assemblehcdtestDebug assembleAndroidTest -DtestBuildType=debug && cd .."
      },
      "android.release": {
        "type": "android.apk",
        "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
        "build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd .."
      }
    },
    "configurations": {
      "ios.sim.debug": {
        "binaryPath": "./ios/build/Build/Products/Debug-iphonesimulator/HuoChaoDuo.app",
        "build": "xcodebuild -workspace ios/HuoChaoDuo.xcworkspace -scheme HuoChaoDuo -configuration debug -sdk iphonesimulator14.4 -derivedDataPath ios/build EXCLUDED_ARCHS=arm64 DETOX=1",
        "type": "ios.simulator",
        "name": "iPhone 11"
      },
      "android.emu.debug": {
        "device": "emulator",
        "app": "android.debug"
      }
    }
  }
4.采坑记录

在detox build时,一直报错,报三方库生成文件资源找不到。
解决方案:将所有的三方库的combile版本和最低版本都和app工程下的版本统一

5.运行效果
image.png

你可能感兴趣的:(「React Native」UI自动化环境搭建(Android))