Configuration
React Native Harness can be configured through a configuration object that defines various aspects of your testing setup.
The most basic configuration would, assuming you support both iOS and Android platforms, look like this:
rn-harness.config.mjs
Entry Point and App Component
React Native Harness needs to know how to locate and integrate with your React Native app.
entryPoint
The path to your React Native app's entry point file.
appRegistryComponentName
The name of the component registered with React Native's AppRegistry.
For Expo projects, the entryPoint should be set to the path specified in the main property of package.json. The appRegistryComponentName is typically set to main for Expo apps.
All Configuration Options
Test Runners
Harness treats metroPort as the preferred starting port. If that port is already in use, Harness tries the next available ports automatically and logs the port it selected for the run.
Physical iOS devices are the exception: they always use the default Metro port and do not support custom or fallback ports.
When multiple Harness runs target the same device, simulator, emulator, or browser configuration, Harness waits for the existing run to finish before starting the next one.
When a run finishes, Harness clears platform-specific dev settings it applied for the session (for example the Android debug HTTP host override and the iOS simulator JS location override) so your next normal Metro or dev-client launch is not stuck pointing at Harness's port.
A test runner defines how tests are executed on a specific platform. React Native Harness uses platform-specific packages to create runners with type-safe configurations.
Runner-specific launch options belong inside each runner config via appLaunchOptions.
They are passed whenever Harness launches or relaunches the app for that runner.
For @react-native-harness/platform-web, browser launch options such as ignoreDefaultArgs belong on the browser config passed to chromium, chrome, firefox, or webkit.
For detailed installation and configuration instructions, please refer to the platform-specific guides:
Default Runner
When you have multiple runners configured, you can specify which one to use by default when no runner is explicitly specified in the CLI command.
If no defaultRunner is specified, you must explicitly provide the --harnessRunner flag when running tests:
Platform Ready Timeout
Permissions
Use the permissions flag to opt into Harness-managed permission prompt handling.
Default: false
When permissions is false, Harness does not start platform-specific permission automation helpers. On iOS that means no XCTest agent session is started for permission auto-accept. Physical iOS devices still require device.codeSign in the runner config when you set permissions: true.
The platform ready timeout controls how long React Native Harness waits for the selected device, simulator, or emulator to become usable. This includes device discovery, simulator or emulator boot, and platform runtime setup before the app is launched.
Default: 300000 (5 minutes) Minimum: 1000 (1 second)
Increase this value if you experience startup failures while:
- Booting cold simulators or emulators
- Starting devices in slower CI environments
Bridge Timeout
The bridge timeout controls the app-side bridge readiness window after Harness launches the app. It does not include simulator or emulator boot time.
Once the app is connected, Harness checks two things while tests run:
- The connection. The app's WebSocket must keep answering pings. It answers them natively, even while JavaScript is busy, so a failure here means the app was killed, froze, or lost its network connection.
- The JS thread. The app's JS thread may be blocked, for example by synchronous work in a test, for as long as the current step allows:
testTimeoutplus 5 seconds while a test or abeforeAll/afterAllhook runs,bundleStartTimeoutwhile a setup file or test file loads, and 20 seconds otherwise. If it stays blocked longer, the run fails with an error naming the test, hook, or file. Harness enforces this from the CLI, sotestTimeoutalso applies to tests that block the JS thread, which a timer inside the app cannot do.
Harness uses bridgeTimeout while waiting for the app runtime to connect, and as the timeout for shorter bridge RPCs such as screenshots or image snapshot matching.
Default: 60000 (60 seconds) Minimum: 1000 (1 second)
Increase this value if Harness times out before the app runtime reports ready, especially on:
- Slower app startup after launch
- Apps that take longer to load the Metro bundle and initialize the Harness runtime
Test Timeout
The test timeout controls how long the runtime allows each test case and suite hook to run before reporting a timeout failure.
Default: 5000 (5 seconds) Minimum: 1000 (1 second)
Harness testTimeout takes precedence over Jest's testTimeout setting so runtime timeout behavior lives next to the rest of your Harness configuration.
Bundle Start Timeout
The bundle start timeout controls how long React Native Harness waits for the launched app to request its Metro bundle.
Default: 60000 (60 seconds) Minimum: 1000 (1 second)
Startup Recovery
Harness can retry app startup automatically when the app fails to come up cleanly during launch.
Default: 2 Minimum: 0
Increase this value if your app occasionally needs another launch attempt before it reaches a ready state, especially in slower CI environments.
Set it to 0 if you want startup failures to fail immediately without any automatic retry.
Diagnostics
Diagnostics record where a run spends its time and how loaded the machine is while it does. They are most useful on slow or flaky CI runners, where you need data to tell a slow simulator boot from a slow bundle or an overloaded host.
Turn them on with diagnostics: true, or set RN_HARNESS_DIAGNOSTICS=1 for a single run without touching your config. Pass an object to tune what is collected:
With the object form, diagnostics are on unless you set enabled: false. Every probe is on by default, and sampleIntervalMs defaults to 5000 (minimum 250). Nothing is started, sampled or written when diagnostics are off.
What is recorded
Besides timings for session setup, Metro bundling, app startup and each test file, Harness samples these metrics every sampleIntervalMs:
On macOS, Harness also records a process listing (telemetry.process_snapshot, the 40 largest processes by memory plus the total process count as host.process_count) when the platform becomes ready, the first time the app becomes ready, and at the end of the run (later app relaunches are not listed again, to keep sampling cheap). For iOS simulators it records platform.ios.simulator.guest_process_count, the number of processes running inside the simulator, at platform ready and at the end of the run, and the platform.ios.simctl.waitForBoot span carries the last boot stage reported by the simulator (bootLastStatus), which shows what a slow or timed-out boot was waiting on.
Output
Everything is written to .harness/diagnostics/ in your project root:
Sampling is paused between runs in watch mode, so idle time does not show up in a run's metrics. Entries recorded while the session shuts down (the end-of-run process listing, for example) are added to the trace of the last run; the key numbers cover the run itself.
The same key numbers are printed at the end of the run. When running in GitHub Actions, they are also added to the job summary as a table.
Plugins
You can register Harness plugins with the plugins option.
Use plugins for project-specific logging, artifact collection, reporting, or workflow automation. See the Plugins guide for more.
Environment-Specific Configurations
You can create different configurations for different environments:
rn-harness.config.mjs
Coverage Root
The coverage root option specifies the root directory for coverage instrumentation in monorepository setups. This is particularly important when your tests run from a different directory than where your source files are located.
Default: process.cwd() (current working directory)
This option is passed to babel-plugin-istanbul's cwd option and ensures that coverage data is collected correctly in monorepo scenarios where:
- Tests run from an
example/directory but source files are in../src/ - Libraries are structured with separate test and source directories
- Projects have nested directory structures that don't align with the current working directory
Without specifying coverage.root, babel-plugin-istanbul may skip instrumenting files outside the current working directory, resulting in incomplete coverage reports.
Set coverage.root when you notice 0% coverage in your reports or when source files are not being instrumented for coverage. This commonly occurs in create-react-native-library projects and other monorepo setups.
Native iOS Coverage
Harness also supports experimental native iOS coverage for selected CocoaPods.
Use this when you want coverage data for native code exercised by your Harness tests. Native coverage currently supports iOS simulators only, with Android planned later. For setup details, see Native Coverage.
