Skip to content

Debugging

When a test fails, spana can drop you into an interactive REPL connected to the live device session. This lets you inspect the screen, try selectors, and experiment with actions before the session is torn down.

Terminal window
spana test --debug-on-failure

When a flow fails, instead of moving to the next flow, spana pauses and opens a REPL:

Entering debug REPL for failed flow "login flow" on android.
Available bindings: app, expect, driver, platform, flowName, error, hierarchy(), selectors(), help()
Use top-level await for async calls, for example: await app.tap({ text: "Login" })
spana:android>
BindingTypeDescription
appobjectFull PromiseApp API — tap, inputText, scroll, etc
expectfunctionAssertion helper, same as in flows
driverobjectRaw driver service for low-level access
platformstringCurrent platform ("web", "android", "ios")
flowNamestringName of the failed flow
errorErrorThe error that caused the failure
hierarchy()asyncReturns the parsed UI element tree
selectors()asyncReturns suggested selectors for visible elements
help()functionPrint all available bindings
spana:android> error.message
'Timed out waiting for selector { testID: "welcome-text" }'
spana:android> await selectors()
[
{ suggestedSelector: { testID: 'login-button' }, elementType: 'Button', text: 'Sign In' },
{ suggestedSelector: { text: 'Welcome' }, elementType: 'Text', text: 'Welcome' },
...
]
spana:android> await app.tap({ text: "Sign In" })
undefined
spana:android> await expect({ testID: "welcome-text" }).toBeVisible()
undefined
spana:android> .exit
  • Use await selectors() to discover what’s on screen — this is the fastest way to find the right selector
  • Use await hierarchy() for the full element tree with bounds, visibility, and nesting
  • All app methods use auto-wait, so await app.tap(...) will retry until the element appears
  • The REPL only activates once per test run (the first failure) to avoid blocking CI
  • The REPL requires an interactive terminal (TTY) — it’s skipped automatically in CI environments
  • Type .exit or press Ctrl+D to leave the REPL and continue the test run