Setting up toets
Order matters here: get one test green on web before adding device platforms, CI or the SDK.
Docs are referenced by slug, for example getting-started: the docs site page /<slug>, also served as markdown at /<slug>.md (until the site is hosted: under docs/ in the toets repository). Package reference pages (reference/<package>/docs/<page>) ship offline in each installed package's docs/; errors print the exact path.
1. Inspect the project
Find out before installing anything:
- The app's framework and which TV platforms it builds for, and the commands that build each (web bundle and port, debug APK, tvOS simulator
.app). - Whether Playwright is already used; toets shares its runner and config file.
- The host OS: Android TV needs macOS or Linux with KVM, tvOS needs macOS with Xcode.
2. Install and configure
Follow getting-started exactly:
@toets/testand@playwright/test, plus one driver package per targeted platform (@toets/driver-web,-android-tv,-tvos).playwright.config.tswithdefineConfigfrom@toets/test: anappentry per platform (how to start the app) and aplatforms.*()project per platform (where tests run). Project names areweb,android-tv,tvos. Options:reference/test/docs/config.- toets does not serve or build the app: use Playwright's
webServerfor the web build; pointapp.androidTV.apkandapp.tvOS.appat build outputs. - App-specific flows (splash, sign-in, consent) go into a fixture in the project, never into toets config. (
guides/writing-tests)
3. First test on web
- Make sure the elements the test needs have test IDs (
testIDin React Native,data-testidon web). - Write one smoke test: launch, navigate to one element, assert focus, press
SELECT, assert the next screen. Use the toets-write-tests skill. npx playwright test --project=webuntil green.
4. Add device platforms
One at a time, each green before the next. Prefer managed devices: toets boots, snapshots and resets emulators and simulators.
- Android TV / Fire TV: Android SDK, an Android TV system image, hardware acceleration. A React Native debug build that loads JS from Metro needs
reversePorts: [8081]in the driver options. (platforms/android-tv) - tvOS: Xcode, a tvOS simulator runtime, an
.appbuilt with-sdk appletvsimulator. (platforms/tvos)
Tests that fail only on a new platform are often real differences (focus engine, missing keys). Use requires for capability gaps; do not branch on the platform. (concepts/capabilities)
5. Optional app cooperation
Each is independent; add only what the tests need.
- Network mocking:
toets: { mock: true }in the config (ormock: { handlers }for baseline handlers every test gets), and the app sends API traffic to the launch payload'smockUrlwith the real origin in a header. (concepts/network-mocking,reference/mock/docs/app-integration) - In-app SDK:
toets: { sdk: true }in the config, and the app starts the SDK; adds idle sync, media state, named states, and app-reported focus for JS focus engines (reportFocus()). Debug or test builds only, never production. (concepts/sdk,reference/sdk/docs/overview,reference/sdk-react-native/docs/react-native)
6. Guardrails for agents and humans
- Add the toets section to the project's
AGENTS.mdfrom the template ingetting-started/agents. - Enable the
@toets/eslint-pluginrecommended config for the test folder. - Install the toets skills if they are not already present. (
getting-started/agents)
7. CI
Read ci first, then the recipe per platform. toets ships no CI actions; adapt the recipes.
- Web: any Linux runner. Android TV: x86_64 Linux with KVM enabled. tvOS: macOS with a pinned Xcode. (
ci/android,ci/tvos) - Build the app once per platform and pass it to test jobs as an artifact.
- Cache system images, AVD snapshots and WebDriverAgent with exact keys. (
ci/caching) - Always upload
playwright-report/,test-results/andtoets-report/(parity matrix), also on failure. (ci/artifacts)
Done when
npx playwright testpasses, or skips with reasons (seetoets-report/parity.md), on every targeted platform locally.- A setup error (
ToetsError: [CODE] ...) was fixed from itsHint:; unknown codes are inreference/core/docs/errors. - CI runs every targeted platform and keeps the report.
- The project's
AGENTS.mdhas the toets section.
Report what was installed, the config decisions (platforms, device mode, app commands) and the verification commands with their results.