@react-native-harness/platforms
v1.6.0
Published
Core platform abstractions for React Native Harness
Readme

Core platform abstractions for React Native Harness - provides the base types and factory functions for creating platform implementations.
Installation
npm install @react-native-harness/platforms
# or
pnpm add @react-native-harness/platforms
# or
yarn add @react-native-harness/platformsUsage
This package provides the core abstractions for creating platform implementations. It's typically used by platform-specific packages rather than directly by end users.
import type { HarnessPlatformRunner } from '@react-native-harness/platforms';
const runner: HarnessPlatformRunner = {
createAppSession: async () => ({
dispose: async () => {
/* kill the launched app */
},
getState: async () => ({ status: 'running' }),
getLogs: () => [],
addListener: () => undefined,
removeListener: () => undefined,
}),
dispose: async () => {
/* clean up platform resources */
},
};API
createHarnessPlatform(params)
Creates a new harness platform instance.
Parameters:
params.name- Unique name for the platformparams.getInstance- Function that returns a platform instance
Returns: HarnessPlatform
HarnessPlatform
Core platform interface.
Properties:
name- Platform namegetInstance()- Returns a platform instance
HarnessPlatformRunner
Platform runner interface with lifecycle methods.
Methods:
createAppSession()- Launches the application and returns anAppSessiondispose()- Cleans up resources
AppSession
One launched application session. Sessions are terminal; restarting means disposing the current session and creating a new one.
Methods:
dispose()- Intentionally kills the launched appgetState()- Returns the cached session stategetLogs()- Returns bounded logs for this launched app sessionaddListener()/removeListener()- Subscribes to minimal session lifecycle events
Error Classes
AppNotInstalledError
Thrown when an app is not installed on a device.
Properties:
bundleId- The bundle ID that wasn't founddeviceName- The device name
DeviceNotFoundError
Thrown when a device is not found.
Properties:
deviceName- The device name that wasn't found
Requirements
- TypeScript support
- Node.js runtime
License
MIT
Made with ❤️ at Callstack
react-native-harness is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. Callstack is a group of React and React Native geeks, contact us at [email protected] if you need any help with these or just want to say hi!
Like the project? ⚛️ Join the team who does amazing stuff for clients and drives React Native Open Source! 🔥
