Files
semantic-release-bot 0d55f9c8c9 chore: 1.2.3
### [1.2.3](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)

### Features

* **react-native-webrtc:** add config mod for Android minSdkVersion 24 ([ff8b167](https://github.com/expo/config-plugins/commit/ff8b1677640a560ca98abd8a83f349b3a1ee9017))

### Other chores

* 1.0.2 ([5f4e900](https://github.com/expo/config-plugins/commit/5f4e90059e4dd69579082aa7531b8ef7d2cc9a72)), closes [#60](https://github.com/expo/config-plugins/issues/60)
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
* **ci:** remove PR title validation action ([#62](https://github.com/expo/config-plugins/issues/62)) ([1648e85](https://github.com/expo/config-plugins/commit/1648e8598b959bf8140a2b984af0b8bb85a7e724))
* **ffmpeg-kit-react-native:** update plugin to use `AndroidConfig.Version.withBuildScriptExtMinimumVersion` ([#60](https://github.com/expo/config-plugins/issues/60)) ([c3a375b](https://github.com/expo/config-plugins/commit/c3a375b292d6405be7b3277d10ab4f8dbb006047))
* 2.1.0 ([e2d2b27](https://github.com/expo/config-plugins/commit/e2d2b27494b6a207932194c680de8cc6c1e7c02e))
* **repo:** add PR template ([#56](https://github.com/expo/config-plugins/issues/56)) ([eee366b](https://github.com/expo/config-plugins/commit/eee366bebcc42f4cdc4623f8b52790e3082a4472))
2022-03-22 18:30:37 +00:00
..
2022-03-22 18:30:37 +00:00
2021-06-23 18:36:21 -06:00
2021-06-23 18:36:21 -06:00
2022-03-22 18:30:37 +00:00
2021-06-23 18:36:21 -06:00
2022-03-22 18:30:37 +00:00
2021-06-23 18:36:21 -06:00

config-plugins/detox

Config plugin to auto configure Detox when the native code is generated (expo prebuild).

Versioning

Ensure you use versions that work together!

expo detox @config-plugins/detox
44.0.0 19.1.0 ^1.1.0
43.0.0 19.1.0 ~1.0.0
40.0.0 18.6.2 ~0.0.0

Most notably, the minimum required Kotlin version changed from 1.3.50 in SDK 40 to 1.4.21 in SDK 43. Failure to use the correct versioning could result in Android build errors like Execution failed for task ':react-native-screens:compileDebugKotlin'. or Execution failed for task ':expo:compileDebugKotlin'..

Add the package to your npm dependencies

Tested against Expo SDK 44

yarn add detox @config-plugins/detox

Detox is an end-to-end (e2e) testing library for iOS and Android. You can use it to automate usage of your native project. This example demonstrates how to use Detox and Jest in a native project that you build locally.

🚀 How to use

  • Install with yarn or npm install
    • Install iOS packages: npx pod-install
  • Run yarn e2e:ios to build and test the iOS app on a simulator (macOS only).
    • This combines yarn build:ios and yarn test:ios.
    • You can run yarn test:ios --watch after building to keep the tests in watch mode.
  • Run yarn e2e:android to build and test the Android app on a Google emulator (Genymotion requires extra config).
    • This combines yarn build:android and yarn test:android.
    • You can run yarn test:android --watch after building to keep the tests in watch mode.
  • Run yarn e2e:android-release to build and test the Android app in release mode.

Recreate this example

  • npx create-react-native-app -t blank
    • cd into the project
  • Install packages:
    • yarn add -D detox @config-plugins/detox @babel/core @babel/runtime @types/jest babel-jest jest jest-circus ts-jest
    • touch tsconfig.json
    • Run expo start to ensure TS is setup correctly.
  • Add the following plugin to your app.json plugins array (before prebuilding). This'll automatically configure the Android native code to support Detox:
    {
      "plugins": ["@config-plugins/detox"]
    }
    
  • Generate the native code expo prebuild
  • Run yarn detox init -r jest

API

The plugin provides props for extra customization. Every time you change the props or plugins, you'll need to rebuild (and prebuild) the native app. If no extra properties are added, defaults will be used.

  • skipProguard (boolean): Disable adding proguard minification to the app/build.gradle. Defaults to false.
  • subdomains (string[] | '*'): Hostnames to add to the network security config. Pass '*' to allow all domains. Defaults to ['10.0.2.2', 'localhost'].

app.config.js

export default {
  plugins: [
    [
      "@config-plugins/detox",
      {
        skipProguard: false,
        subdomains: ["10.0.2.2", "localhost"],
      },
    ],
  ],
};

FAQ

If the following commands fail, you can get better debug info by running a subset command:

  • yarn e2e:ios: yarn ios (builds the iOS app). xcodebuild compile errors may show in a more helpful format (using xcpretty).
  • yarn e2e:android: yarn android (builds the Android app). Android compile errors may show in a more helpful format.

yarn e2e:android failed

If you get the error:

detox[98696] ERROR: DetoxRuntimeError: Cannot boot Android Emulator with the name: 'Pixel_API_28'

HINT: Make sure you choose one of the available emulators: Pixel_3_API_30,Pixel_3a_API_30,Pixel_C_API_30

Be sure to change the first emulator name (in my case "Pixel_API_28") with one of the suggested emulators (in my case Pixel_3_API_30, Pixel_3a_API_30, Pixel_C_API_30), in the detox.config.js file under devices.emulator.device.avdName. More emulators can be created in Android Studio.


If you get the error:

Error: app binary not found at '/Users/.../with-detox/android/app/build/outputs/apk/debug/app-debug.apk', did you build it

It means the build step failed, ensure running yarn android, and yarn build:android works before trying yarn e2e:android again.


If you get the error:

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Be sure to disable any proxies running on your computer that may be blocking requests (i.e. Charles Proxy). You may need to run yarn clean:android before attempting to build again.

📝 Notes