Skip to main content
skill CX Codex

detox-skill — Claude Code skill: what it does, how to install

Generates Detox E2E tests for React Native projects in JavaScript and TypeScript. Sets up tests for local emulators and TestMu AI cloud runs.

MIT 252 installs ★ 393 updated 2026-10-13

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add LambdaTest/agent-skills --skill detox-skill -a claude-code
Open on GitHub

What detox-skill does

This skill directs the assistant to write Detox E2E tests for React Native. Detox synchronizes actions automatically. Because of this, the skill drops arbitrary timeouts in favor of native framework synchronization. It covers element selectors by testID, accessibility labels, and gestures like swipes or multi-taps.

The instructions also structure .detoxrc.js configs for Android and iOS builds. For remote pipelines, the skill outlines API requests to trigger Espresso or XCUITest runs on TestMu AI. Cloud execution fails without configured LT_USERNAME and LT_ACCESS_KEY credentials.

What it helps with

  • generate Detox login and navigation test suites
  • configure .detoxrc.js for Android emulators and iOS simulators
  • trigger Espresso and XCUITest builds on TestMu AI via curl
  • replace manual wait timeouts with native Detox synchronization

Example prompts for the agent

  • Write a Detox E2E test for the checkout flow using testID selectors
  • Generate a .detoxrc.js configuration for iPhone 16 simulator and Pixel 7 emulator
  • Prepare curl scripts to upload test APKs and run Espresso on LambdaTest

How to install detox-skill

1Skills CLI (Vercel)

npx skills add LambdaTest/agent-skills --skill detox-skill -a claude-code

2Manually: put the files in place

~/.claude/skills/detox-skill/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/detox-skill/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about detox-skill

How to install detox-skill in Claude Code?

Run npx skills add LambdaTest/agent-skills --skill detox-skill -a claude-code in your terminal. You can also copy the content directly to ~/.claude/skills/detox-skill/SKILL.md.

What does detox-skill do?

It provides Detox automation patterns for React Native in JavaScript and TypeScript. The agent uses it to produce test scripts, element matchers, and device actions without manual delays.

What is required to run tests on TestMu AI cloud?

You must provide $LT_USERNAME and $LT_ACCESS_KEY credentials. Built app and test artifacts are uploaded via curl to LambdaTest endpoints before executing on real devices.

Source text

SKILL.md · MIT
---
name: detox-skill
description: >
  Generates Detox E2E tests for React Native apps in JavaScript. Gray-box testing
  framework with automatic synchronization. Supports local simulators/emulators
  and TestMu AI cloud. Use when user mentions "Detox", "React Native test",
  "element(by.id())", "device.launchApp". Triggers on: "Detox", "React Native E2E",
  "React Native test", "element(by.id)", "device.launchApp".
languages:
  - JavaScript
  - TypeScript
category: mobile-testing
license: MIT
metadata:
  author: TestMu AI
  version: "1.0"
---

# Detox Automation Skill

You are a senior React Native QA engineer specializing in Detox.

## Core Patterns

### Basic Test

```javascript
describe('Login', () => {
  beforeAll(async () => {
    await device.launchApp();
  });

  beforeEach(async () => {
    await device.reloadReactNative();
  });

  it('should login with valid credentials', async () => {
    await element(by.id('emailInput')).typeText('[email protected]');
    await element(by.id('passwordInput')).typeText('password123');
    await element(by.id('loginButton')).tap();
    await expect(element(by.id('dashboardTitle'))).toBeVisible();
    await expect(element(by.text('Welcome'))).toBeVisible();
  });

  it('should show error for invalid credentials', async () => {
    await element(by.id('emailInput')).typeText('[email protected]');
    await element(by.id('passwordInput')).typeText('wrong');
    await element(by.id('loginButton')).tap();
    await expect(element(by.id('errorMessage'))).toBeVisible();
  });
});
```

### Matchers (Finding Elements)

```javascript
element(by.id('uniqueId'))                    // testID prop (best)
element(by.text('Login'))                      // Text content
element(by.label('Submit'))                    // Accessibility label
element(by.type('RCTTextInput'))              // Native type
element(by.traits(['button']))                 // iOS traits

// Combined
element(by.id('list').withDescendant(by.text('Item 1')))
element(by.id('item').withAncestor(by.id('list')))

// At index (multiple matches)
element(by.text('Delete')).atIndex(0)
```

### Actions

```javascript
await element(by.id('btn')).tap();
await element(by.id('btn')).longPress();
await element(by.id('btn')).multiTap(3);
await element(by.id('input')).typeText('hello');
await element(by.id('input')).replaceText('new text');
await element(by.id('input')).clearText();
await element(by.id('scrollView')).scroll(200, 'down');
await element(by.id('scrollView')).scrollTo('bottom');
await element(by.id('item')).swipe('left', 'fast');
await element(by.id('input')).tapReturnKey();
```

### Expectations

```javascript
await expect(element(by.id('title'))).toBeVisible();
await expect(element(by.id('title'))).not.toBeVisible();
await expect(element(by.id('title'))).toExist();
await expect(element(by.id('title'))).toHaveText('Welcome');
await expect(element(by.id('toggle'))).toHaveToggleValue(true);
await expect(element(by.id('input'))).toHaveValue('hello');
```

### Device Control

```javascript
await device.launchApp({ newInstance: true });
await device.reloadReactNative();
await device.sendToHome();
await device.terminateApp();
await device.installApp();
await device.shake();                       // Shake gesture
await device.setLocation(37.7749, -122.4194); // GPS
await device.setURLBlacklist(['.*cdn.example.*']); // Block URLs
```

### Anti-Patterns

| Bad | Good | Why |
|-----|------|-----|
| `waitFor().withTimeout()` everywhere | Trust Detox auto-sync | Detox waits automatically |
| No `testID` on components | Add `testID` prop | Stable selectors |
| `device.launchApp()` in every test | `device.reloadReactNative()` | Faster |
| Manual delays | Detox synchronization | Built-in waiting |

### .detoxrc.js Configuration

```javascript
module.exports = {
  testRunner: { args: { config: 'e2e/jest.config.js' } },
  apps: {
    'ios.debug': {
      type: 'ios.app',
      binaryPath: 'ios/build/MyApp.app',
      build: 'xcodebuild -workspace ios/MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
    },
    'android.debug': {
      type: 'android.apk',
      binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
      build: 'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
      reversePorts: [8081],
    },
  },
  devices: {
    simulator: { type: 'ios.simulator', device: { type: 'iPhone 16' } },
    emulator: { type: 'android.emulator', device: { avdName: 'Pixel_7_API_34' } },
  },
  configurations: {
    'ios.sim.debug': { device: 'simulator', app: 'ios.debug' },
    'android.emu.debug': { device: 'emulator', app: 'android.debug' },
  },
};
```

## Cloud Execution on TestMu AI

Detox generates native test runners (Espresso for Android, XCUITest for iOS). Run on TestMu AI cloud by uploading the built artifacts and triggering a framework build.

### Android (Espresso) Cloud Run

```bash
# 1. Build the app and test APKs
detox build --configuration android.emu.debug

# 2. Upload app APK
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
  -F "appFile=@android/app/build/outputs/apk/debug/app-debug.apk" \
  -F "name=DetoxApp"
# Response: {"app_url": "lt://APP_ID", ...}

# 3. Upload test APK
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
  -F "appFile=@android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk" \
  -F "name=DetoxTestSuite"
# Response: {"app_url": "lt://TEST_SUITE_ID", ...}

# 4. Trigger Espresso build
curl -X POST "https://mobile-api.lambdatest.com/framework/v1/espresso/build" \
  -H "Authorization: Basic <BASE64_AUTH>" \
  -H "Content-Type: application/json" \
  -d '{
    "app": "lt://APP_ID",
    "testSuite": "lt://TEST_SUITE_ID",
    "device": ["Galaxy S21 5G-12", "Pixel 6-12"],
    "build": "Detox-Android",
    "deviceLog": true,
    "video": true
  }'
```

### iOS (XCUITest) Cloud Run

```bash
# 1. Build the iOS app and test runner
detox build --configuration ios.sim.release

# 2. Create .ipa from the build artifacts, then upload
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
  -F "[email protected]" -F "name=DetoxApp"

# 3. Upload test runner .ipa
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
  -F "[email protected]" -F "name=DetoxTestSuite"

# 4. Trigger XCUITest build
curl -X POST "https://mobile-api.lambdatest.com/framework/v1/xcui/build" \
  -H "Authorization: Basic <BASE64_AUTH>" \
  -H "Content-Type: application/json" \
  -d '{
    "app": "lt://APP_ID",
    "testSuite": "lt://TEST_SUITE_ID",
    "device": ["iPhone 14-16", "iPhone 13-15"],
    "build": "Detox-iOS",
    "devicelog": true,
    "video": true
  }'
```

## Quick Reference

| Task | Command |
|------|---------|
| Build iOS | `detox build --configuration ios.sim.debug` |
| Test iOS | `detox test --configuration ios.sim.debug` |
| Build Android | `detox build --configuration android.emu.debug` |
| Test Android | `detox test --configuration android.emu.debug` |
| Specific test | `detox test --configuration ios.sim.debug e2e/login.test.js` |
| Record video | `detox test --record-videos all` |
| Take screenshot | `await device.takeScreenshot('login-page')` |

## Setup

```bash
npm install detox --save-dev
npm install jest jest-circus --save-dev
detox init
```

## React Native Component Setup

```jsx
// Add testID to components for Detox
<TextInput testID="emailInput" placeholder="Email" />
<TextInput testID="passwordInput" placeholder="Password" secureTextEntry />
<Button testID="loginButton" title="Login" onPress={handleLogin} />
<Text testID="errorMessage">{error}</Text>
```

## Deep Patterns

For advanced patterns, debugging guides, CI/CD integration, and best practices,
see `reference/playbook.md`.

© TestMu AI · MIT · LambdaTest/agent-skills

Similar skills

All skills for Testing and QA →

From the same set47

The whole set →
cucumber-skill Creates Gherkin feature files and matching step definitions. Use it to turn application behavior into Cucumber BDD scenarios. CX Codex +1 283installs webdriverio-skill Generates WebdriverIO end-to-end tests in JavaScript or TypeScript for local runs and TestMu AI cloud. CX Codex +1 265installs cypress-skill Generates production-grade E2E and component tests in JavaScript or TypeScript. Runs tests locally or on TestMu AI cloud, understands Cypress commands, and writes tests with proper selectors and network interception. CX Codex +1 264installs robot-framework-skill robot-framework-skill turns a described scenario into a .robot test in keyword-driven syntax, with SeleniumLibrary for browser flows and RequestsLibrary for API checks. CX Codex +1 253installs hyperexecute-skill This skill prepares and runs HyperExecute test jobs, checks YAML locally, connects CI, and helps investigate failed cloud runs. CX Codex +1 250installs xcuitest-skill Generates XCUITest UI tests for iOS and iPadOS apps. Detects whether to use local Xcode simulators or TestMu AI cloud devices, then builds test code accordingly. CX Codex +1 248installs puppeteer-skill Generates Puppeteer scripts for browser automation, scraping, and PDF output. Activates when you mention Puppeteer, headless Chrome, page.goto, or PDF generation. CX Codex +1 247installs testng-skill Generates Java TestNG tests with groups, data providers, parallel execution, suite XML, and listeners. Use it when building or organising TestNG coverage. CX Codex +1 243installs

Project sponsors

Companies that keep this analytics open