Skip to content

Debugging toets failures ​

toets failures are designed to explain themselves: errors carry a hint and a docs slug, and every failed test has a failure dump. Read before changing anything. The full guide is guides/debugging-failures.

Docs are referenced by slug, for example concepts/idle: 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.

Workflow ​

  1. Read the error. A thrown error prints ToetsError: [CODE] message, Hint: (likely cause and fix) and Docs: (a slug, plus its offline path in node_modules). Follow the hint first. Any code: reference/core/docs/errors. A failed assertion prints expected and received state, the focused element and idle status.

  2. Read the failure dump (test-results/<test>/toets-failure.md, path printed with the failure): focused element, text snapshot of the screen, last keys pressed, busy resources, recent logs and requests; toets-screenshot next to it. The text snapshot shows which test IDs exist and what is focused. (reference/core/docs/failure-dumps)

  3. Read the steps in the report (npx playwright show-report): every action is a step. For a screenshot and text snapshot after every step, rerun with toets: { steps: { screenshot: true, snapshot: true } }. Find the first step where reality diverged from intent; that is usually earlier than the failing line.

  4. Reproduce narrowly, without retries:

    sh
    npx playwright test e2e/home.spec.ts:12 --project=android-tv --retries=0
    npx playwright test e2e/home.spec.ts --repeat-each=10   # flaky?
  5. Explore live if needed with the toets MCP server (launch, press, snapshot): the same primitives as tests.

  6. Fix the cause, then rerun on every platform.

Symptoms ​

SymptomLikely cause and fix
Element not found on one platformTest ID missing or not mapped there. Check the text snapshot; add the ID in the app. (concepts/locators-and-assertions)
Focus on the wrong elementOverlay, focus memory or that platform's focus engine rules. Assert focus after each step to find where it diverged. (concepts/focus)
FOCUS_STUCK, FOCUS_LOOP, FOCUS_UNREACHABLEThe message lists where focus went. Stuck: end of a row, a trap or a disabled target. Loop: the target is not in that direction. Possibly an app bug.
Timeout naming a busy resourceApp never idle (poller, animation, player). Exclude the noise in the SDK config, or fix the app. (concepts/idle)
Unsupported key / capability errorThe remote lacks the key. Add requires, or a key override if the app has a gesture for it. (concepts/remote-and-keys)
Negative assertion passes, bug still thereIt ran before the state existed. Anchor it on a positive assertion first. (concepts/idle)
tvOS: a press right after a screen change does nothingThe new screen had no focus yet, so tvOS dropped the press. Assert focus on the new screen before pressing, not visibility. (platforms/tvos)
Passes on web, fails on deviceSlower device, stricter focus engine, missing key. Compare text snapshots between platforms. (platforms/tvos, platforms/android-tv)
NO_KEYBOARD, CHAR_NOT_ON_KEYBOARDThe field's app keyboard is not declared, or its layers/keys/space miss a key. Compare the declaration with a snapshot of the keyboard's root. (concepts/text-input)
TEXT_NOT_ENTEREDThe field shows other text after typing: a key typed something else, the app capped or reformatted it, or fill did not clear first (declare clear or backspace). (reference/core/docs/text-input)
Stuck behind an open keyboardThe dump's keyboard: line says which. Close it the way a user does: app.keyboard.submit() or Key.BACK. (reference/core/docs/failure-dumps)
DEEPLINK_UNHANDLED, DEEPLINK_INVALIDThe message names the translated link. Unhandled: the app's intent filter, CFBundleURLTypes scheme or web route is missing, or the config's deepLink mapper translates wrongly. Invalid: not an absolute URL, or the mapper threw. (concepts/deep-links)
Deep link lands on the wrong screen or without focusThe dump's last launch / last deep link lines show the translation the platform opened. No focus after landing is an app bug. (reference/core/docs/deep-links)
SDK_NOT_CONNECTED after a deep link launchAn Android splash or router activity dropped the intent extras (the launch payload). It must forward them. (concepts/deep-links)
React Native debug build: red box, SDK_NOT_CONNECTEDThe app could not load its bundle from Metro. Android TV: reverse Metro's port with the driver option reversePorts: [8081]. (reference/driver-android-tv/docs/traps)
JS focus engine: Focused: nothingThe app reports a view it resolved from React internals (_reactInternals, a fiber's stateNode). Report a ref or a findNodeHandle tag instead. (reference/sdk-react-native/docs/focus)
Mock not appliedtoets.mock off, handler added after launch(), or the app never routed the request: check app.network.requests(). (concepts/network-mocking)
Launch or device errorsRead driver and device logs; check the platform's app config and host requirements. (platforms/web)
Fails in CI onlyMissing KVM, cold boots, uncached WebDriverAgent, fewer CPUs. (ci/android, ci/tvos)

Never ​

  • Add sleeps or waitForTimeout.
  • Raise a timeout without evidence the operation is legitimately slow.
  • Add retries to make a flaky test pass.
  • Weaken or delete an assertion so a buggy app passes. If the app is wrong, report it and leave the test failing (or mark it with test.fail() and a reason, if the maintainers agree).
  • Switch to app.platformOnly to work around a gap.

Report back ​

State the root cause, the evidence (dump, step, log line), the fix, and the commands you ran to verify on which platforms.