Skip to main content
Momentic resolves environment variables from three places, in order of precedence:
  1. CLI flags (e.g. --env-file, --env)
  2. The enclosing shell when inheritFromShell: true is set on an environment
  3. momentic.config.yaml, either inline under envVariables or loaded from an envFile / JSON file
See environments for the full schema.

Reserved variables

These are set automatically at runtime and accessible in any step via {{ env.NAME }}:
VariableDescription
BASE_URLBase URL of the current environment
CURRENT_URLURL of the page being tested
ENV_NAMEName of the current environment
TEST_NAMEName of the test being executed

Runtime variables

Required by the CLI, MCP server, and dashboard integrations:
VariablePurpose
MOMENTIC_API_KEYAuthenticates with the dashboard. Required for CI, MCP, and uploads.
CIWhen set to true, enables CI-only behavior (e.g. cache saving).
MOMENTIC_LOG_LEVELdebug, info (default), warn, error.

Accessing in tests

Use the templating syntax anywhere a step accepts a string:
- id: 488b...
  type: PRESET_ACTION
  command:
    id: a2ba...
    type: TYPE
    target:
      type: description
      elementDescriptor: Email field
    value: "{{ env.USERNAME }}"
Or access env.VARIABLE directly inside a JavaScript step.

Setting at runtime

Use setVariable inside a JavaScript step to write a variable:
setVariable("OTP_CODE", await fetchOtp());
Or use the Save to environment variable option on any step with a return value (e.g. AI extract, JavaScript).