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 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
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 how long React Native Harness waits for the app to report runtime readiness after it has been launched. It does not include simulator or emulator boot time.
Default: 60000 (60 seconds) Minimum: 1000 (1 second)
Increase this value if you experience timeout errors, especially on:
- Complex test suites with heavy setup
- Slower app startup after launch
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.
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.
