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.driveroverrides 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. modelandosVersiontell the device provider what to boot or lease, e.g.model: 'tv_1080p', osVersion: '34'.keyboardsdeclares 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 onlydefineKeyboard: 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
deepLinkmapper in itsappconfig or a project'sapp(deep links). - Relative app paths (
apk,app) resolve against the config file's directory. - Options merge from the top-level
toetsinto each project'stoets. Theappentry for the platform merges with the project'sapp. - Snapshot baselines are per project, not per host. toets projects default
snapshotPathTemplateto Playwright's default without the host OS suffix; a top-level or projectsnapshotPathTemplatewins. - The parity reporter is added after your reporters;
parityReport: falseturns it off. Without areporter, toets useslist(dotin CI) andhtml(open: 'never'), sonpx playwright show-reportworks.
toets option | Meaning |
|---|---|
sdk | Wait for the in-app SDK on launch (adds idle sync, app focus, media, launch states). |
mock | Run a host-side mock server per worker (network.mock): true or its settings. |
keyOverrides | How a semantic key is performed for this app. Flagged in reports. |
timeouts | actionMs, sdkConnectMs, navigationSettleMs. Assertions use expect.timeout. |
remote | intervalMs between repeat/sequence presses (100), longPressMs (1000). |
idle | quietMs, budgetMs: how long assertions wait for idle before polling. |
steps | Attach a screenshot and/or text snapshot after every action (costly on devices). |
video | off, 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.