How Momentic uses caching to improve test performance
Momentic improves test performance by caching element data. Most steps run in milliseconds by avoiding repeated AI lookups, while still maintaining accuracy.
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.
This allows Momentic to reuse known element data across test runs instead of re-identifying it every time.Momentic will bust the existing cache if the target element changes significantly or if the templated description is different than what was cached.Caches are only ever saved on successful test runs. Additionally, the test run must be eligible for cache saving (see below).
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 to true.
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.
Disabling cache may drastically increase test duration and non-determinism.
You can disable caching globally by passing the --disable-cache flag when running tests:
Copy
Ask AI
npx momentic run --disable-cache
You can disable caching on a per-step basis in the step options. This is useful when the target element is dynamic and changes between test runs (e.g., “last item in list”)