Advanced Test Creation
This guide covers the features that go beyond basic instruction/validation steps: code execution scripts, reusable modules, variable extraction, and control flow.Code Execution Scripts
Code execution blocks let you run Python, JavaScript, TypeScript, or Bash code as part of a test. Common uses: seed a database, generate test data, call an API, or clean up state.Create a script
Write a script file:Use the script in a test
Reference the script by name in acode_execution block:
Inline code (no saved script)
For one-off code that doesn’t warrant a saved script, use inline code blocks:Manage scripts with the CLI
Manage scripts with the Python SDK
Reusable Modules
Modules are shared groups of test blocks that can be imported into any test. Common uses: login flows, onboarding sequences, setup/teardown routines.Create a module
Write a YAML file with ablocks array:
Import into a test
module_id.
Seed a test with a module at creation time
Manage modules with the CLI
Variables
Variables let you pass dynamic data between steps using Mustache-style{{variable}} templates.
Extract a value
Useextraction blocks to pull data from the screen into a named variable:
Use the variable in later steps
Set variables up front
Define variables intest.metadata for credentials or configuration:
Manage test variables with the CLI
Control Flow
If / Else
Conditional branches let tests adapt to different app states:While loops
Repeat steps until a condition is met:Full Example: E2E Checkout with Everything
This test combines code execution (DB seeding), module import (login), extraction (order number), conditional flow (promo code), and validation:Authoring Best Practices
- One action per instruction step. Don’t combine “tap X and type Y” into one block.
- Separate validations. Keep assertions in their own
validationblocks. - Validate durable outcomes. Check user-visible state (e.g. “inbox is visible”) not transient state (e.g. “loading spinner disappeared”).
- Use variables for secrets. Never hardcode credentials in reusable tests.
- Put modules at the top. Shared setup flows belong at the beginning.
What’s Next
- YAML Schema — full block type reference
- YAML Control Flow — detailed if/while documentation
- Python SDK Reference — ScriptClient and ModuleClient APIs
- First Test Guide — getting started from scratch