Test context
Values that steps have access to during execution
Accessing data
All steps has access to the following variables:
env
: An object containing any configured environment variables, as well as any dynamic variables set throughsetVariable
during the test. The following variables are automatically set in theenv
object:BASE_URL
: the starting URL of the test.CURRENT_URL
: the current URL of the active page. This is updated after every step.
results
: An array containing the results of steps executed during the test. This array will be continuously updated throughout the test as more steps are completed. Each element of the array corresponds to thedata
field of the step output, which can be viewed in the test editor UI.
In a module
Modules have their own context that is independent from any tests that include them. They can also be passed data via parameters and inputs. This can be useful when you need to test similar scenarios with different inputs.
When editing a module, you can add parameters to the module definition and use them in the module steps using the {{ }}
syntax. Reference module parameters using the following syntax {{ inputs.PARAMETER_NAME }}
.
Updating data
You can use the special setVariable
function within JavaScript steps to modify the env
global object. Non-serializable values such as functions and circular objects will be rejected.
The function signature of setVariable
function is as follows:
function setVariable(name: string, value: unknown);
In a module
Modules do automatically inherit all values on env
from its parent test at the time of execution. This means that if you modify env
inside a Module, it will not affect the parent test context.
Was this page helpful?