Skip to content

Android TV / Fire TV ​

Runs the app on Android TV emulators through Appium UiAutomator2. toets manages the Appium server and, by default, the emulators: one per worker, created from an Android TV system image, snapshotted and reset between tests. Package: @toets/driver-android-tv.

ts
import { defineConfig, platforms } from '@toets/test';

export default defineConfig({
  app: { androidTV: { apk: './build/app-debug.apk', package: 'com.example.tv' } },
  projects: [platforms.androidTV({ model: 'tv_1080p', osVersion: '34' })],
});

Host: the Android SDK with an Android TV system image, and hardware acceleration (macOS, or Linux with KVM). See Android TV on Linux for CI.

AspectAndroid TV
Test IDview resource ID
Focusthe focused view, or the SDK's focus when connected
KeysAndroid keycodes; all TV keys including color, numeric, channel and media
Launchlaunch payload as the __toets intent extra; host ports forwarded with adb reverse
Artifactslogcat, screen recording (toets.video)

Options (SDK path, Appium, remote profile, logcat, managed emulators): Android TV setup and devices.

Devices ​

ModeWho owns the emulator
managedtoets: creates, boots, snapshots, resets and shuts down emulators (default)
externalyou: running devices, devices: { mode: 'external' } with TOETS_DEVICES=emulator-5554,emulator-5556
commandyour scripts: shell commands lease and release devices (device farms, lease brokers)

Fire TV ​

Fire TV apps (Fire OS) are Android apps; test them on Android TV emulators with platforms.androidTV({ remote: 'fire-tv' }), which limits the keys to the Alexa Voice Remote's. Amazon services (IAP, ADM) are not on Android TV images; fake them in the app's test build. Vega OS is not supported. See Fire TV.

Traps ​

  • Emulators need hardware acceleration. Without KVM or the macOS hypervisor they are too slow to be useful.
  • First boot is slow; later boots are not. Managed mode snapshots a booted emulator and restores it. Keep the AVD and snapshot cached in CI.
  • localhost on the device is the device. toets forwards the ports in the launch payload; if your app talks to other host services (Metro for React Native debug builds), list their ports in reversePorts or use the mock server. See traps.
  • Resource IDs need to be set. Views without an ID are invisible to getByTestId; React Native sets it from testID.