Skip to main content
Momentic’s AI evaluates assertions against the DOM, accessibility tree, and a screenshot of the viewport. The same rules from Finding elements apply, plus a few specific to assertions.

Best practices

  • Keep assertions short and specific. Aim for under 20 words; split compound assertions into multiple steps.
  • Provide context. Point at the relevant region of the page and define any non-standard terminology.
  • Remove ambiguity. The answer should be clearly true or false given the page state. When in doubt, use single quotes for exact text matches.

Good assertions

Bad assertions

Pre-trained behavior

Typos

The agent tolerates minor typos. john@@gmail.com will match john@gmail.com. For exact matching, wrap the expected value in single quotes and instruct the agent explicitly: the username is exactly 'john@@gmail.com'. do not allow any typos. When generating test data programmatically, prefer long, distinct values to avoid accidental matches.

Run assertions

Run assertions are plain-English statements you expect to have been true at some point during the run — including transient UI like toasts, spinners, and pop-ups that appear and disappear too quickly for a step-based assertion to catch. They are evaluated after the run finishes by an AI agent that samples frames from the run’s video recording, and any failed run assertion fails the run. Video recording is automatically enabled for tests that define them. Currently available for web tests.
The same best practices apply, with one difference: run assertions may describe a sequence (“X appears, then Y”) because the agent evaluates the whole timeline rather than a single moment.

ffmpeg requirement

Evaluating run assertions with the CLI requires ffmpeg to sample video frames. If any test in a run defines run assertions, the CLI checks for ffmpeg before executing and exits with an error when it is missing. Install it with your package manager:
  • macOS: brew install ffmpeg
  • Debian/Ubuntu: apt-get install ffmpeg
  • Windows: winget install ffmpeg (or choco install ffmpeg)
The CLI uses the first ffmpeg on PATH. To use a specific binary instead, set the MOMENTIC_FFMPEG_PATH environment variable to its full path. Cloud runs evaluate run assertions on Momentic’s infrastructure and do not require a local ffmpeg. GitHub-hosted Actions runners (ubuntu-latest, macos-latest) already include ffmpeg; slim container images may not.