Skip to main content
A module is a named sequence of steps you can call from any test. Use modules to share login flows, setup fixtures, or repeated user journeys.
Modules can’t call other modules.
Editing a module updates every test that uses it.

Example

A module is a YAML file that ends in .module.yaml. Call it from any test with a Module step.
login.module.yaml
fileType: momentic/module
moduleId: 68aab6c6-...
name: log-in
parameters:
  - USERNAME
  - PASSWORD
steps:
  - id: ccde...
    type: PRESET_ACTION
    command:
      id: 488b...
      type: TYPE
      target:
        type: description
        elementDescriptor: username input
      value: "{{ env.USERNAME }}"
  - id: 90ba...
    type: PRESET_ACTION
    command:
      id: a2ba...
      type: TYPE
      target:
        type: description
        elementDescriptor: password input
      value: "{{ env.PASSWORD }}"
  - id: 0886...
    type: PRESET_ACTION
    command:
      id: 5385...
      type: CLICK
      target:
        type: description
        elementDescriptor: login button
checkout.test.yaml
fileType: momentic/test
name: checkout-flow
baseUrl: https://saucedemo.com
steps:
  - id: dae7...
    type: MODULE
    moduleId: 68aab6c6-...
    inputs:
      USERNAME: [email protected]
      PASSWORD: "{{ env.TEST_PASSWORD }}"
  - id: c8e6...
    type: AI_ACTION
    text: Add a "Gravity Blanket" to the cart and check out
  - id: 8966...
    type: PRESET_ACTION
    command:
      id: abdd...
      type: AI_ASSERTION
      assertion: The order confirmation page is shown

Parameters

Parameters let a single module handle different inputs. Keys are strings; values can be any JSON-compatible value.
Module parameters
Declare parameters in the module’s config, then reference them inside steps via {{ env.PARAM_NAME }} (or env.PARAM_NAME in JavaScript steps).

Defaults vs instance inputs

Each parameter can have a default input value (shared by every instance of the module) and an instance input value (set on a specific Module step). Instance inputs take precedence.
checkout.test.yaml
steps:
  - id: dae7...
    type: MODULE
    moduleId: 68aab6c6-...
    inputs:
      USERNAME: [email protected] # instance input, overrides default
      PASSWORD: "{{ env.TEST_PASSWORD }}"
Instance inputs are JavaScript expressions, so you can template from the outer test’s env.

Caching

Modules are uncached by default and always execute. Enable caching to skip a module when its cache key and inputs are unchanged. The module’s return value (the return value of its last step) is also cached.
Module cache settings

Authentication modules

Enable Treat as auth module to save and restore browser auth state between runs. Momentic persists:
Set the cache expiry shorter than your session’s expiry. Add a final step that verifies the authenticated state so the cache only saves when login succeeded.