Plugins
Harness plugins are the way to extend Harness beyond what it offers out of the box.
Use them to add project-specific capabilities on top of Harness, such as native coverage collection, custom reporting, artifact collection, or workflow-specific automation.
A plugin can react to events such as:
- Harness startup and teardown
- run start and finish
- runtime ready and disconnect events
- Metro initialization and bundle events
- app lifecycle signals
- collection, suite, and test execution events
Each plugin receives a context with useful runtime information such as a logger, project root, current runner, current config, and hook-specific data like the run ID or test file path.
Defining a Plugin
Use definePlugin() from @react-native-harness/plugins and register the plugin in your Harness config.
Then register it in rn-harness.config.mjs:
Typical Uses
Plugins are a good fit when you want to:
- write custom logs for run start, finish, or failures
- collect screenshots, crash artifacts, or extra diagnostics
- send results to external reporting systems
- trigger project-specific automation around test runs
Keep plugins focused on workflow needs that are specific to your app or team.
Available Events
The full list of plugin events is defined in the source here:
The public plugin shape is based on nested objects like run.started, runtime.ready, metro.bundleFinished, app.exited, or harness.beforeDispose.
