/qa-mobile:detox-testingfrom qa-mobile
Provides end-to-end testing guidance for React Native apps using Detox's gray-box architecture with by.id, by.text, and by.label matchers, waitFor sync, and Jest runner.
Ships in qa-mobile. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Detox's "gray-box" architecture is load-bearing: unlike Appium (black-box, external server), it runs in the app's process (per detox-docs), so it "automatically monitors asynchronous operations to eliminate test flakiness at its core" (detox-docs) - tracking network calls, animations, and timers without explicit sync hooks.
If the app is native iOS/Android (not RN), use
xcuitest-suite or
espresso-suite. For
non-RN-specific cross-platform, see
appium-testing.
npx detox init (Step 1).testID props to the RN components the tests will target (Step 4).detox build (Step 2).e2e/*.test.js specs using element(by.id(...)) matchers, actions,
and assertions (Step 3, references/element-api.md).waitFor(...).withTimeout(N) only where Detox's auto-sync misses a
genuine async condition (Step 5).detox test --configuration <cfg> and iterate until green (Step 6).npm install --save-dev detox
npx detox init # scaffolds .detoxrc.js + e2e/ directory
.detoxrc.js configures device + app + runner; the default
template is sensible.
# Android
detox build --configuration android.emu.debug
# iOS
detox build --configuration ios.sim.debug
The build configuration in .detoxrc.js references the project's
existing build commands (Gradle / xcodebuild) - Detox doesn't
introduce a new build pipeline.
Verify: detox build must finish and emit the app binary before Step 6.
If it fails, fix the underlying native build error (Gradle / xcodebuild) and
re-run - the fix lives in the RN build config, not Detox.
Match elements with element(by.id(...)); prefer by.id (the RN testID
prop) for stable, translation-proof lookups. The full matcher catalog,
combinators, action verbs, and assertions are in
references/element-api.md.
Example test:
describe('Cart flow', () => {
beforeAll(async () => {
await device.launchApp();
});
beforeEach(async () => {
await device.reloadReactNative();
});
it('adds item to cart', async () => {
await element(by.id('product-BOOK-001')).tap();
await element(by.id('add-to-cart-button')).tap();
await expect(element(by.id('cart-count'))).toHaveText('1');
});
it('applies promo code', async () => {
await element(by.id('promo-input')).typeText('WELCOME10');
await element(by.id('apply-promo-button')).tap();
await expect(element(by.id('subtotal'))).toHaveText('$22.49');
});
});
testIDIn RN production code:
<TouchableOpacity testID="add-to-cart-button" onPress={addToCart}>
<Text>Add to cart</Text>
</TouchableOpacity>
<TextInput testID="promo-input" value={code} onChangeText={setCode} />
testID is React Native's prop for accessibilityIdentifier
(iOS) / resource-id (Android). Detox finds elements by it.
waitFor for explicit syncWhen Detox's automatic tracking misses something:
await waitFor(element(by.id('async-result')))
.toBeVisible()
.withTimeout(10000);
await waitFor(element(by.id('progress-bar')))
.not.toBeVisible()
.whileElement(by.id('list')).scroll(100, 'down');
waitFor(...).withTimeout(N) polls the condition for up to N ms.
whileElement(...) performs an action (scroll) while waiting -
useful for "scroll until visible."
detox test --configuration android.emu.debug
detox test --configuration ios.sim.debug
# Specific test file
detox test e2e/cart.test.js --configuration ios.sim.debug
# Headless mode
detox test --headless
Verify: assert every spec reports green. If one fails, read the Detox error
(element not found / timeout), fix the matcher or add a waitFor (Step 5),
and re-run that spec before wiring CI. Detox then runs headless on CI
platforms such as Travis CI, CircleCI, and Jenkins (per detox-docs).
jobs:
detox-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- run: npm ci
- uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
script: |
detox build --configuration android.emu.debug
detox test --configuration android.emu.debug --headless
detox-ios:
runs-on: macos-15
steps:
- uses: actions/checkout@v5
- run: npm ci
- run: npx pod-install
- run: |
detox build --configuration ios.sim.debug
detox test --configuration ios.sim.debug
A React Native store app needs an E2E check that adding a book to the cart updates the badge count.
<TouchableOpacity testID="product-BOOK-001">
and the cart badge renders <Text testID="cart-count"> (Step 4).detox build --configuration ios.sim.debug (Step 2).e2e/cart.test.js with the 'adds item to cart' spec from Step 3.detox test e2e/cart.test.js --configuration ios.sim.debug (Step 6).1, with no sleep anywhere in the test.| Anti-pattern | Why it fails | Fix |
|---|---|---|
Querying by by.text for translatable strings | Translation breaks tests. | Use by.id (testID) for stable lookups (Step 3). |
await sleep(2000) between actions | Detox's auto-sync is the point; sleeps mask real flake. | waitFor(...) for genuine async; trust auto-sync otherwise. |
Skipping device.reloadReactNative() between tests | State leaks; tests pollute each other. | beforeEach reload (Step 3 example). |
by.type('RCTView') (iOS-specific class) | Tests break on Android (different class name). | Use by.id (cross-platform) or platform-conditional code. |
| Per-test app reinstall | Slow; Detox's reload is faster. | device.reloadReactNative() over device.launchApp(). |
| Long-press without device wake | Simulator may be in screensaver; tap misses. | device.shake() / device.openURL() to wake. |
xcuitest-suite or
appium-testing.by.id, by.text, by.label, by.type, by.traits), combinators,
actions, and assertions.xcuitest-suite,
espresso-suite,
appium-testing,
maestro-flows - alternatives.evals/eleven-green-runs-over-a-broken-checkout/criteria.json (opens in a new tab)evals/eleven-green-runs-over-a-broken-checkout/task.md (opens in a new tab)evals/german-launch-turned-nineteen-specs-red/criteria.json (opens in a new tab)evals/german-launch-turned-nineteen-specs-red/task.md (opens in a new tab)evals/reinstall-before-every-spec-tripled-the-ci-bill/criteria.json (opens in a new tab)evals/reinstall-before-every-spec-tripled-the-ci-bill/task.md (opens in a new tab)evals/reorder-spec-cannot-reach-the-row-it-needs/criteria.json (opens in a new tab)evals/reorder-spec-cannot-reach-the-row-it-needs/task.md (opens in a new tab)evals/suite-froze-when-pull-to-refresh-shipped/criteria.json (opens in a new tab)evals/suite-froze-when-pull-to-refresh-shipped/task.md (opens in a new tab)references/element-api.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
8 skills in this plugin
/appium-testingUse for any question or task about Appium mobile UI tests, even a quick fix, including tests that break after an Appium upgrade and suites that pass on Android but fail on iOS: one suite for iOS and Android (native or React Native) with XCUITest, UiAutomator2 and Espresso drivers, capabilities, clients in JS, Python, Java, Ruby or .NET, simulators, emulators and device farms./espresso-suiteUse whenever an Android app needs UI tests in Google's Espresso: onView with perform and check, automatic synchronization instead of sleeps, IdlingResource for app async work, ./gradlew connectedAndroidTest and JUnit XML results./flutter-testingUse whenever a Flutter app needs tests: unit tests with flutter test, widget tests with testWidgets and WidgetTester, integration_test on simulators, emulators or devices, choosing the layer per change, mockito with build_runner, LCOV coverage and CI.npx claudepluginhub testland/qa --plugin qa-mobileOther plugins' skills for the same job