@config-plugins/detox

中文文档
11.0.0发布于 2025/06/03MITTypeScriptCommonJS近 30 天下载 18.7万

Config plugin to auto configure detox on prebuild

原始使用文档
文档目录8 节
  1. Versioning
  2. Add the package to your npm dependencies
  3. 🚀 How to use
  4. Recreate this example
  5. API
  6. FAQ
  7. yarn e2e:android failed
  8. 📝 Notes

config-plugins/detox

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

Versioning

Ensure you use versions that work together!

expodetox@config-plugins/detox
53.0.020.37.0^10.0.0
52.0.020.28.0^9.0.0
51.0.020.20.3^8.0.0
50.0.020.17.0^7.0.0
49.0.020.11.0^6.0.0
48.0.020.5.0^5.0.0
47.0.019.13.0^4.0.0
46.0.019.9.0^3.0.0
45.0.019.6.9^2.0.0
44.0.019.1.0^1.1.0
43.0.019.1.0~1.0.0
40.0.018.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

First install the package with yarn, npm, or npx expo install.

npx expo install 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 npx 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_6_Pro_API_33,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_6_Pro_API_33, 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.


If you get the error:

CLEARTEXT communication to [some host] not permitted by network security policy

This means you're attempting to connecting over plain HTTP (not HTTPS) to a host that isn't in your subdomains settings (defaults to ['10.0.2.2', 'localhost']). Set your subdomain settings appropriately. For example, if you're building Detox into a dev-client, you'll want to make sure you can connect to your Metro server:

module.exports = {
  plugins: [
    [
      "@config-plugins/detox",
      {
        subdomains:
          process.env.EAS_BUILD_PROFILE === "development"
            ? "*"
            : ["10.0.2.2", "localhost"],
      },
    ],
  ],
};

📝 Notes

版本与发布记录

@config-plugins/detox 共发布 18 个版本,首次发布于 2021/06/15;过去 12 个月发布了 0 个版本。

版本发布日期距今
11.0.0latest2025/06/031.4 年前
9.0.02024/12/041.9 年前
8.0.02024/05/092 年前
7.0.02024/02/072 年前
6.0.02023/07/153 年前
5.0.12023/03/103 年前

关于 @config-plugins/detox 的常见问题

@config-plugins/detox 是什么?

Config plugin to auto configure detox on prebuild

如何安装 @config-plugins/detox?

在项目目录运行 npm install @config-plugins/detox,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:expo(^53)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@config-plugins/detox 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@config-plugins/detox 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@config-plugins/detox 可以商用吗?

@config-plugins/detox 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@config-plugins/detox 的下载量有多少?

根据 npm 官方下载统计,@config-plugins/detox 在 2026/10/11 – 2026/11/09 这 30 天内被下载 187,042 次,日均约 6,235 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@config-plugins/detox 还在维护吗?

最新版本 11.0.0 发布于 2025/06/03(1.4 年前);至今共发布 18 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/06/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。