Test Variables
Seed initial variable values that steps can read and overwrite at run time
Variables let you seed a set of values that are available throughout the test. Individual steps can read them and update them as the test runs.
Editing Variables
- Open the test in the test editor.
- Click the Parameters tab, then Variables.
The editor shows this signature above the body you write:
function variables(): Record<string, unknown> {Write the function body only. The function must return a plain object:
return {
start_date: "2025-01-01",
limit: 10,
page: 1,
};Returning an array is rejected. The values you return here are loaded as the initial _VARS object for the test.
Allowed Values
Return values must be JSON-serializable. Accepted types: strings, finite numbers, booleans, null, arrays, and plain objects. These are rejected at save time:
undefined- functions, symbols, bigints
- non-finite numbers (
Infinity,NaN) - non-plain objects (class instances, circular references)
import and export statements are not available. If your code references faker, the faker library is automatically available.
Limits
| Limit | Value |
|---|---|
| Execution timeout | 250 ms |
| Memory | 64 MB |
| Max output size | 256 KB |
| Source size | 64 KB |
Saving
Click Save Parameters & Variables. SmoothDeploy runs your code before saving. If it fails or returns invalid output, a toast error appears and the save is blocked.
Referencing Variables in Steps
Any step field with a reference picker supports variable tokens. Open the picker, choose a variable name, and it inserts {{vars.key}} into the field.
In the generated Playwright script, {{vars.key}} compiles to a lookup on _VARS:
await page.getByTestId('order-number').fill(_VARS['orderId']);Runtime Assignment
Steps that capture data during a run write directly into _VARS. For example, an extract-text step saves the captured value before the next step runs:
_VARS['confirmationCode'] = (await page.locator('[data-id="code"]').textContent()) ?? '';The variables you seed in the editor provide initial values. Extract and generate steps can add new keys or overwrite existing ones as the test progresses.