detox-testing
БесплатноБез исполняемых скриптовНе проверенUse whenever a React Native app needs end-to-end tests with Detox: gray-box runs inside the app, by.id, by.text and by.label matchers, waitFor for extra sync…
от testland★ 18 звёзд на GitHubОб этом скилле
detox-testing
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.
When to use
- The app is React Native (the framework's intended use case).
- Speed matters more than cross-stack reuse (Detox is faster than Appium for RN apps).
- The team uses Jest (Detox's default runner; built-in integration).
If the app is native iOS/Android (not RN), use
xcuitest-suite or
espresso-suite. For
non-RN-specific cross-platform, see
appium-testing.
How to use
- Install Detox and scaffold with
npx detox init(Step 1). - Add
testIDprops to the RN components the tests will target (Step 4). - Build the app for the target device configuration with
detox build(Step 2). - Author
e2e/*.test.jsspecs usingelement(by.id(...))matchers, actions, and assertions (Step 3, references/element-api.md). - Add
waitFor(...).withTimeout(N)only where Detox's auto-sync misses a genuine async condition (Step 5). - Run
detox test --configuration <cfg>and iterate until green (Step 6). - Wire build + test into CI as a headless job (Step 7).
Step 1 - Install
npm install --save-dev detox
npx detox init # scaffolds .detoxrc.js + e2e/ directory
.detoxrc.js configures device + app + runner; the default
template is sensible.
Step 2 - Build the app for testing
# 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.
Step 3 - Author tests with matchers
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');
});
});
Step 4 - Production code: set testID
In 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.
Step 5 - waitFor for explicit sync
When 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."
Step 6 - Run
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).
Step 7 - CI integration
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
Установить detox-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл detox-testing?
Use whenever a React Native app needs end-to-end tests with Detox: gray-box runs inside the app, by.id, by.text and by.label matchers, waitFor for extra sync, and the Jest runner. Flutter is flutter-testing; cross-platform black-box is appium-testing; YAML flows are maestro-flows.
Как установить скилл detox-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл detox-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic