Skip to content

Config ​

A toets suite is a Playwright Test suite with one project per platform. defineConfig and platforms.* from @toets/test build it.

ts
// playwright.config.ts
import { defineConfig, platforms, Key } from '@toets/test';

export default defineConfig({
  testDir: 'e2e',
  app: {
    web: { url: 'http://localhost:8080' },
    androidTV: { apk: 'build/app.apk', package: 'com.example.tv' },
    tvOS: { app: 'build/App.app', bundleId: 'com.example.tv' },
  },
  toets: { sdk: true, mock: true },
  projects: [
    platforms.web(),
    platforms.androidTV({ model: 'tv_1080p', osVersion: '34' }),
    platforms.tvOS({ toets: { keyOverrides: { FAST_FORWARD: { as: Key.RIGHT, holdMs: 800 } } } }),
  ],
});

Principles ​

  • Everything Playwright stays Playwright. workers, retries, reporter, grep, expect.timeout, UI mode and sharding work unchanged.
  • One project per platform. A project name defaults to the platform (web, android-tv, tvos); add more projects for more devices of one platform.
  • Drivers load lazily by package name: @toets/driver-web, @toets/driver-android-tv, @toets/driver-tvos. Install only the ones you use. driver overrides the module (a package or a path relative to the config file).
  • One flat options object per project. platforms.androidTV({ ... }) takes Playwright project fields (name, retries, use, ...), toets's keys (driver, app, model, osVersion, devices, toets) and the driver's options (e.g. remote: 'fire-tv'), typed by the driver package. A custom driver passes its type: platforms.web<MyOptions>({ driver: './my-driver.ts', ... }).
  • Every config type is exported from @toets/test, driver option types included (WebDriverOptions, AndroidTvDriverOptions, TvosAppConfig, ...), so a config can be factored into typed pieces without importing driver packages.
  • model and osVersion tell the device provider what to boot or lease, e.g. model: 'tv_1080p', osVersion: '34'.
  • keyboards declares the app-drawn keyboards (text input): top level, per project (platforms.web({ keyboards })) or per test (test.use({ keyboards })). Each level replaces the one above, never merges. Keep the definitions in a file that imports only defineKeyboard: the config loads it.
  • Deep links keep one canonical URL in tests; each platform's form (a web path, a Fire TV intent) is the deepLink mapper in its app config or a project's app (deep links).
  • Relative app paths (apk, app) resolve against the config file's directory.
  • Options merge from the top-level toets into each project's toets. The app entry for the platform merges with the project's app.
  • Snapshot baselines are per project, not per host. toets projects default snapshotPathTemplate to Playwright's default without the host OS suffix; a top-level or project snapshotPathTemplate wins.
  • The parity reporter is added after your reporters; parityReport: false turns it off. Without a reporter, toets uses list (dot in CI) and html (open: 'never'), so npx playwright show-report works.
toets optionMeaning
sdkWait for the in-app SDK on launch (adds idle sync, app focus, media, launch states).
mockRun a host-side mock server per worker (network.mock): true or its settings.
keyOverridesHow a semantic key is performed for this app. Flagged in reports.
timeoutsactionMs, sdkConnectMs, navigationSettleMs. Assertions use expect.timeout.
remoteintervalMs between repeat/sequence presses (100), longPressMs (1000).
idlequietMs, budgetMs: how long assertions wait for idle before polling.
stepsAttach a screenshot and/or text snapshot after every action (costly on devices).
videooff, on, retain-on-failure, where the driver supports video.

TV trap: one worker per device ​

Each worker drives one device. workers above the number of devices you can run (emulators are heavy; tvOS simulators need a Mac each) makes workers wait for or fail to get a device. Start with workers: 1 on device projects.