Skip to main content

Documentation Index

Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

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.
log-in.module.yaml
fileType: momentic/module/v2
moduleId: log-in
name: Log in
parameters:
  - USERNAME
  - PASSWORD
defaultParameters:
  USERNAME: [email protected]
steps:
  - type:
      text: "{{ env.USERNAME }}"
      into: Username input
  - type:
      text: "{{ env.PASSWORD }}"
      into: Password input
  - click: Log in
checkout.test.yaml
fileType: momentic/test/v2
id: checkout-flow
url: https://saucedemo.com
steps:
  - module:
      path: ../modules/log-in.module.yaml
      inputs:
        USERNAME: [email protected]
        PASSWORD: "{{ env.TEST_PASSWORD }}"
  - act: Add a "Gravity Blanket" to the cart and check out
  - assert: The order confirmation page is shown

Parameters

Parameters let a single module handle different inputs. Declare them on the module, then reference them inside steps via {{ env.PARAM_NAME }} (or env.PARAM_NAME in JavaScript steps).
Module parameters

Defaults vs instance inputs

Each parameter can have a default value on the module and an instance input on a specific Module step. Instance inputs take precedence and are JavaScript expressions, so they can template from the outer test’s env.
checkout.test.yaml
steps:
  - module:
      path: ../modules/log-in.module.yaml
      inputs:
        USERNAME: [email protected] # instance input, overrides default
        PASSWORD: "{{ env.TEST_PASSWORD }}"

Control flow

Default retries

Set Default retries under the module’s Control flow tab to retry every invocation of the module a fixed number of times on failure. Invocations that set their own retries value override the module default. Use this for flaky setup modules (e.g. a login module that sometimes fails on slow environments) instead of setting retries on every invocation.

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.