agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/testing/detox/SKILL.md

detox

Skill15 starsChanged 45 days agoMITView on GitHub

Expert Detox mobile E2E automation for React Native applications on iOS and Android. Use when running gray-box integration tests, simulating device interactions, or debugging mobile flakiness.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Problem: Test flakiness due to timing differences across mobile platforms.

    line 86
  2. Very specific:

    Use testID for Element Matching: Assign testID="my_element" on React Native components for unambiguous cross-platform matching.

    line 110
  3. Very specific:

    Run on Release/Staging Builds in CI: Test release configurations (configuration: "ios.sim.release") for accurate performance metrics.

    line 112
  4. Distinctive:

    Use Mock Servers (MSW or MockServer): Keep external API calls deterministic and isolated from external network outages.

    line 113
  5. Distinctive:

    Use sleep timeouts: Trust Detox's automatic idle synchronization instead of arbitrary delays.

    line 117
  6. Distinctive:

    Test third-party social auth webviews with Detox: Mock the auth response in the React Native state layer.

    line 118

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Detox

Detox is designed for React Native. Unlike Appium (Black-box), Detox works "Gray-box" by running inside your app, monitoring the main thread. It knows when the app is busy/idle, eliminating flaky waits.

When to Use

  • Gray-Box Mobile E2E Automation: Testing React Native mobile apps with internal synchronization on iOS and Android.
  • Flake-Free Mobile Testing: Eliminating manual sleep() calls by synchronizing automatically with React Native's bridge and event queue.
  • High-Velocity Release Validation: Validating critical user journeys on simulators and emulators in mobile CI/CD pipelines.
  • Fast Local Feedback: Running automated mobile UI tests alongside the React Native packager.

Quick Start

describe("Example", () => {
  beforeAll(async () => {
    await device.launchApp();
  });

  it("should show hello screen after tap", async () => {
    await element(by.id("hello_button")).tap();
    await expect(element(by.text("Hello!!!"))).toBeVisible();
  });
});

Core Concepts

Gray-Box Synchronization Architecture

Detox monitors the app internally (network requests, animations, timers, UI layout passes) and executes actions only when the app is completely idle:

[ Detox Test Runner ] ──(WebSocket)──→ [ Native Detox Agent (Inside App) ]
                                              ├── Monitors React Native Bridge
                                              ├── Tracks Ongoing Network Requests
                                              └── Waits for Zero Pending Animations

Matchers & Actions Hierarchy

Interacts with native elements using accessibility IDs:

// e2e/checkout.test.ts
import { by, element, expect } from "detox";

describe("Checkout Flow", () => {
  beforeAll(async () => {
    await device.launchApp({ newInstance: true });
  });

  it("adds item to cart and proceeds to payment", async () => {
    await element(by.id("item_card_101")).tap();
    await element(by.id("add_to_cart_btn")).tap();

    await expect(element(by.id("cart_badge"))).toHaveText("1");
    await element(by.id("cart_icon")).tap();
    await element(by.id("checkout_button")).tap();

    await expect(element(by.text("Payment Options"))).toBeVisible();
  });
});

Device Control & Deep Linking

Controls simulator state, permissions, and URL schemes:

it("handles incoming deep links", async () => {
  await device.openURL({ url: "myapp://promo/summer2026" });
  await expect(element(by.id("promo_banner"))).toBeVisible();
});

Common Patterns

Synchronized User Flow with Test IDs

Problem: Test flakiness due to timing differences across mobile platforms.

Solution: Assign testID props in React Native and query using by.id:

describe("Authentication Flow", () => {
  beforeAll(async () => {
    await device.launchApp({ delete: true });
  });

  it("logs in with valid credentials", async () => {
    await element(by.id("email_input")).typeText("user@example.com");
    await element(by.id("password_input")).typeText("secret123");
    await element(by.id("login_button")).tap();
    await expect(element(by.id("welcome_header"))).toBeVisible();
  });
});

Best Practices

Do:

  • Use testID for Element Matching: Assign testID="my_element" on React Native components for unambiguous cross-platform matching.
  • Disable Infinite Animations during Tests: Infinite loops keep the app permanently busy, preventing Detox from synchronizing.
  • Run on Release/Staging Builds in CI: Test release configurations (configuration: "ios.sim.release") for accurate performance metrics.
  • Use Mock Servers (MSW or MockServer): Keep external API calls deterministic and isolated from external network outages.

Don't:

  • Use sleep timeouts: Trust Detox's automatic idle synchronization instead of arbitrary delays.
  • Test third-party social auth webviews with Detox: Mock the auth response in the React Native state layer.
  • Ignore detox build artifacts: Capture videos and artifacts on failure (--record-videos failing --take-screenshots failing).

Troubleshooting

ErrorCauseSolution
DetoxRuntimeError: App synchronization failedContinuous background loops, animations, or timers blocking sync.Disable indefinite timers in test mode or use device.disableSynchronization().
Cannot find simulator/emulatorDevice name in detox configuration does not exist in local SDK.Run xcrun simctl list or emulator -list-avds and update .detoxrc.js.
Test failed: Element not foundNative view missing testID or collapsed in hierarchy.Ensure testID is passed to the underlying native component and visible on screen.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.