Acts as a global store for variables to read and write across tests. Like any global scope, use it sparingly. Prefer it for shared configuration (for…
Markdown (no JavaScript)
# Environment Acts as a global store for variables to read and write across tests. Like any global scope, use it sparingly. Prefer it for shared configuration (for example: base URLs, modes, timeouts) rather than per-step data. Open a `type: env` file in VS Code to get the **environment panel** on the right (YAML stays on the left). Click {{btn:edit:Edit Environment}} to edit variables, presets, settings, and certificates — see [Edit Environment](./edit.md). Toolbar actions on the environment panel: | Control | What it does | |---|---| | {{btn:check:Apply}} | Push variables from this env file into the workspace Environment panel (uses current preset selections). Matching environment-layer keys are updated; runtime rows with the same name are kept (and still win when resolving `e:`). | | {{btn:clear-all:Clear}} | Remove only the keys defined in this env file from the workspace panel. Other manual/runtime values stay. | The same runtime values are also available in the [Environment variables panel](./ui.md) in the Multimeter bottom panel.  ## Define an environment file ```yaml type: env variables: api_url: local: "http://localhost:8080" # key-value map (named choices) staging: "https://staging.example.com" prod: "https://test.mmt.dev" mode: dev: "debug" prod: "release" # Nested choice value — one concept; use e:city.latitude / e:city.longitude city: berlin: latitude: 52.52 longitude: 13.41 tokyo: latitude: 35.68 longitude: 139.69 timeouts: - 1000 # array list (allowed values) - 2000 - 5000 presets: runner: dev: api_url: local # picks choice "local" from the variable map mode: dev prod: api_url: prod mode: prod setting: http: version: "auto" timeout: 30000 ``` Notes - `variables` values must be one of: - **key-value map** (named choices) — each choice may be a **scalar** or a **nested object/array**. Prefer one concept when fields must stay together for **API defaults** (e.g. `city.berlin: {latitude, longitude}`), then APIs read `e:city.latitude`. A preset (or the Environment panel) selects a choice by key; without a preset the first choice is the default. For env vs JSON catalogs vs values written in a test, see [Where values live](../../tasks/start-a-project.md#where-values-live-env-vs-json-vs-direct). - **array list** (allowed values) — scalars only; a preset or user picks from the list - **live variable** — a `./….mmt` path that runs another file on each `e:name` read (see [Live variables](./live-variables.md)) - `presets` groups can be hierarchical; `runner.dev` is a common pattern. Skip presets when a single choice map already is the concept (as with `city` above). ## Usage Supported token forms in tests and APIs: | Syntax | Where to use | Type behavior | |--------|-------------|---------------| | `<<e:var>>` | Anywhere in a string (URLs, `headers`, `body` text) | Always substituted as string | | `e:var` | As the entire value after `: ` (colon + space) | Preserves type (number, boolean, string) | | `{{e:var}}` | Unquoted whole value or inside strings (normalized to bare / `<<e:…>>` on parse) | Same as the form it rewrites to | What to use when - Use `<<e:var>>` when you want substitution anywhere in a string (inside URLs, headers, or other text). - Use `e:var` only when it appears as the entire value after `: `; types are preserved (numbers, booleans, strings). - You can append **accessors** to either form when you need only part of the `value:` - `<<e:token[0]>>` — first character / item - `<<e:token[0:6]>>` — string or array slice (end-exclusive) - `<<e:user.name>>` — property access Notes - `e:var` is not replaced inside plain text like `hi:e:var there`; it must follow `: `. - Bare `{{var}}` (no `e:` / `i:` / `r:` / `c:` prefix) is not an env token — use `<<e:var>>`, `e:var`, or `{{e:var}}`. - `<e:var>` and `e:{var}` are ordinary text, not tokens. - Full token rules: [Dynamic values — syntax](../../features/dynamic-values/syntax.md). - Slice form `[start:end]` uses normal JS `slice(start, end)` semantics. - Random (`r:`) and current (`c:`) tokens use the same syntax and accessors — see [Dynamic values](../../features/dynamic-values/index.md). Examples: ```yaml url: <<e:api_url>>/login headers: Authorization: Bearer <<e:token>> X-Token-Prefix: <<e:token[0:6]>> body: username: e:user password: e:pass first_letter: <<e:user[0]>> ``` ## Environment elements - [Quick start](./quick-start.md) · [Environment variables panel](./ui.md) · [Edit Environment](./edit.md) · [Live variables](./live-variables.md) - [CLI](./cli.md) · [Settings](./settings.md) · [Project root](./project-root.md) · [Reference](./reference.md) · [Use environments](../../tasks/use-environments.md)
For AI agents · llms.txt · Home