How caching works
Caching is automatically applied to most interactive steps such as Click and Type. When these steps are executed, Momentic stores contextual information about the targeted element, including:- CSS selectors and HTML attributes.
- Accessibility roles and metadata.
- Screenshots and visual cues.
- Element location and dimensions.
Cache saving eligibility
A test run is always eligible if the
--save-cache
flag is passed.- If the test is running in a CI environment, the test is eligible for cache
saving. This is defined by the environment variable
CI
being set totrue
. - If the test is not running in a CI environment, caches are saved when running on a branch not configured as a main branch or protected branch. These branches are specified in the project configuration.
Where caching is never applied
- Steps like AI check or AI extract which rely on dynamic evaluation.
- Steps with variables that have continuously changing values (e.g.
CLICK the {{ Date.now() }} timer
).
Disabling cache
Disabling cache may drastically increase test duration and non-determinism.
--disable-cache
flag when
running tests:
How cache keys are generated
Cache keys are based on:- The step’s unique ID.
- IDs of any parent modules.
- The resolved element description.
- Dynamic template values (e.g.,
{{ env.USERNAME }}
).
Storage and expiration
Cache is:- Securely stored on Momentic Cloud.
- Isolated per organization and only accessible during authenticated test runs.
- Automatically expired after 90 days of inactivity.
Failed steps and caching
Cache is only created when a step successfully executes. Failed steps do not generate or store cache entries.Git-based caching
In order to ensure that tests continue to run smoothly while engineers are making changes concurrently, caches are isolated by git branch when possible:- For the main branch (configured in
momentic.config.yaml
), caches are stored for each commit. This allows new branches to seed their caches from main. - For non-main branches, only the latest caches are stored.
- When a new branch is created based off of main, its caches will be seeded with the latest values before the merge base commit.
- When a feature branch is merged into the main branch, the caches from the merged branch and the previous commit on main are combined it order to ensure consistency with both previous runs on the main branch as well as checks that passed in that branch’s CI.