Skip to main content
Momentic tests and modules are YAML files. The on-disk format favors readable, human-editable shapes: single-key command aliases, natural-language targets, and no volatile IDs. Web (momentic) and mobile (momentic-mobile) are separate CLIs that share this format. The shapes on this page apply to both; only the command set and targeting differ. For the full list of commands, see the Web steps reference and the Mobile steps reference.

File shapes

A test is YAML with a fileType, a readable kebab-case id, and a list of steps. A module uses a module fileType and adds a human-readable name. Both use the same id key for their stable identifier.
A web test sets the starting url.
checkout.test.yaml
log-in.module.yaml
Each module parameter is { name, default?, enum? }. default is a value object ({ string } or { javascript }) used when an invocation does not supply an input for that parameter.

Before and after sections

Alongside steps, a test can declare optional before and after sections. They are sibling top-level keys with the same step shape as steps. In the editor these are the Setup (before) and Teardown (after) sections.
checkout.test.yaml
  • before runs first, then steps, then after.
  • If a before step fails, the main steps are skipped and the test is marked as a setup failure.
  • after runs after the main steps regardless of whether they passed, which makes it the right place for teardown (resetting state, deleting test data).
Use before for prerequisites the main steps assume, most commonly authentication.
before and after run only when the whole test runs. Running a single step, or running “from” / “until” a step in the main body (common while editing), skips both sections. If a mid-body run starts on a logged-out page, it is because the before section that logs in did not run. Run the whole test to exercise it.

Step shapes

Every step is one of:
  • A bare command alias for commands that take no options (web: - refresh, - goBack; mobile: - killApp, - openNotifications).
  • A simplified single-key scalar where the string is the target description (- click: Submit, - tap: the Submit button).
  • A detailed single-key object when the command needs more than a description.
  • An AI action: - act: <goal>, or a detailed form with goal and version.
  • A module invocation: - module: <relative path or id>, or a detailed form with path and inputs.
  • A conditional with one if key.
  • A while loop with one while key.
Detailed options always live under the command key; sibling top-level keys are rejected. Shared metadata such as retries, skipped, comment, and saveAs can be set on any step. saveAs stores the step’s return value on env.<NAME> for later steps to read.

Targets

Target-bearing commands take a natural-language description of the element. The key name varies by command (on, into, from, that, and so on), which the command reference lists per command.
Web commands also accept a CSS selector (css) or absolute coordinates (coords, or split x / y when a coordinate needs templating). The css field also accepts XPath expressions; Momentic auto-detects XPath (for example //button[@type='submit']).

Commands

Each command is a single-key alias. The available commands differ by platform: A few shorthands are worth knowing: doubleClick: Submit is shorthand for click: { on: Submit, times: 2 }, and rightClick: Submit is shorthand for click: { on: Submit, rightClick: true }.

AI actions and assertions

act performs a goal in natural language. assert checks a condition and fails the test by default. extract pulls a value and fails the step when the payload does not match its schema, storing the result on env.<saveAs>.
See Agentic testing and Writing assertions for usage patterns.

Element checks

checkElement<...> aliases are deterministic assertions against a single element. They take a target and, where relevant, a name and value. Aliases compose a subject and a condition:
  • Subjects: Element (existence-style: Exists, Visible, Enabled, Editable, Focused), ElementContent, ElementAttribute, ElementName, ElementStyle (content-style: Contains, Equals, StartsWith).
  • Each positive condition has a paired negation, e.g. DoesNotExist, NotVisible, DoesNotContain, DoesNotEqual, DoesNotStartWith.
The target is element (or css / coords / x+y).

Conditionals

A conditional is a single if key holding exactly one condition plus a then list. The condition is an inline assert, an element or screen check, or a javascript expression. There is no else; use a separate step instead.

While loops

A while loop is a single while key holding a do list plus a loop control: an optional condition and an optional maxIterations cap. At least one of the two must be present. The condition takes the same forms as a conditional (an inline assert, an element or screen check, or a javascript expression) and is re-evaluated before every iteration. The do steps run each pass and share the test’s env, so a step that writes a variable with saveAs is visible to the condition on the next iteration.
Provide only maxIterations to repeat a fixed number of times:

Modules

Module invocations reference a module file with a path relative to the file that contains the invocation:
Each value in inputs is one of:
  • A shorthand string, evaluated as a JavaScript expression. Use this to reference env vars (env.PARAM) or call helpers. It is not mustache templating.
  • { string: ... }: a literal string.
  • { javascript: ... }: the script’s return value is bound to the parameter.
When a module takes no inputs, the scalar form is enough:
See Modules for parameters, defaults, and caching.

File references

Relative file references resolve from the YAML file containing the step, not from the project root and not from the test file when the step is inside a module.

Variables and templating

Any string field can include {{ expression }} templating, evaluated at runtime against the test’s env map. Use saveAs on any step to write its return value to env.<NAME> for later steps. See Variables for setting and reading values across steps.

Durations

Every duration written in the simplified format is milliseconds. Format converters translate to and from the internal second-based fields automatically:

IDs

The format omits per-step and per-command IDs from disk. The runtime mints fresh internal IDs on load. Step-cache continuity across saves is preserved by the snapshot identity cache, so cached steps stay cached after a reorder or file move when the content is stable. See Step cache and Auto-heal for cache behavior on reruns.