From momentic-test
Creates, runs, and maintains mobile E2E tests for Android and iOS using Momentic. Manages cache, timing, and settings for reliable execution on emulators and simulators.
How this skill is triggered — by the user, by Claude, or both
Slash command
/momentic-test:momentic-mobile-testThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Momentic Mobile drives real Android emulators and iOS simulators. Tests are
Momentic Mobile drives real Android emulators and iOS simulators. Tests are ordered lists of structured mobile steps.
Momentic caches resolved mobile step metadata such as native selectors, XML nodes, visible text, webview state, and coordinates so most runs avoid repeated AI calls. This is critical for speed, but stale cache is a real debugging possibility: a step may hit the wrong element. AI checks may also use past-result memory to stay consistent across runs; bad memory can explain repeated borderline failures.
Caches are scoped by git metadata, including branch. Cache writes are skipped on
protected branches, including the configured main branch, unless cache saving is
forced with --save-cache or the CI environment variable is set. Cache reads
can still happen on protected branches. Use --disable-cache to bypass cache
entirely.
Ways to force fresh behavior:
--disable-cache for dynamic targets that should resolve fresh every run,
such as today's date or the next available slot.CacheId into splice with
--cache-id <CacheId>.Momentic uses smart waiting before targeting steps. It waits up to the configured smart-waiting timeout, which defaults to 5 seconds, for device state to settle or the target to appear. Within that window, do not add manual waits. For slower or more semantic readiness, use a targeted element/screen check, an AI check, or a native wait only when the test genuinely needs fixed time.
momentic.config.yaml sets project defaults, but many mobile settings can be
overridden at the test level: platform, default app asset channel/tag, emulator
provider, local device/app overrides, locale/timezone, geolocation, timeouts,
headers, and environment. Always check the test's own metadata before assuming
the project default applies.
For managed mobile assets, treat channels from momentic_get_artifacts() as
the source of truth. settings.defaultChannel must be a real channel for the
test platform. settings.defaultTag is optional; omit it to use the most recent
uploaded tag for that channel. Do not assume "latest" is special unless that
literal tag exists.
Each run has a test-scoped env context that persists across steps, including
modules. Later steps can read values written by earlier steps.
saveAs on steps with return values.--env-key.return plus saveAs / --env-key; use
setVariable(name, value) when setting multiple variables.env.NAME in JavaScript and module input expressions.{{ env.NAME }} in string fields. {{ ... }} can evaluate JavaScript,
but do not use it inside JavaScript step source because env is already in
scope there.Module inputs are JavaScript fragments as strings. Quote literal strings and use
env.X for variables; they are not {{ }} templates.
Mobile JavaScript steps run in the mobile execution sandbox. Use them for short one-off data prep, API checks, assertions, or context writes that native mobile steps cannot express.
The sandbox commonly provides env, setVariable, axios, assert, and other
Momentic-provided helpers. If exact JS support matters, check the JavaScript
command docs or the Step Authoring Guide from momentic_session_start.
Keep short one-off JavaScript inline. In v2 YAML, reusable utilities and long
scripts can live in a project script file, following existing project
conventions. Prefer locations such as
$MOMENTIC_PROJECT_ROOT/scripts/mobile-utilities/setup.js when the project
already has a scripts/ pattern. Read nearby scripts first and match their
module style, helper naming, env usage, and error style.
Mobile tests are *.test.yaml files. Mobile modules are reusable step
collections stored as *.module.yaml files. Test IDs are authoritative and live
on the test file's id field.
There are two major mobile file formats:
fileType: momentic/mobile-test/v2 or
fileType: momentic/mobile-module/v2 -> mobile v2. Direct YAML editing is
preferred for high-confidence localized changes when live device discovery is
not needed.fileType, or any other value -> v1. Never edit v1 YAML
directly; persist changes only through momentic_test_splice_steps.Mobile v2 tests include a required platform value: ANDROID or IOS.
Platform-specific command availability matters. Do not add Android-only commands
to iOS tests.
momentic.config.yaml is the project root config. It stores project defaults
for agents, AI features, emulator settings, file globs, environments, mobile
assets, cache behavior, and advanced settings.
Mobile v2 steps can reference local files by relative path:
module: ./modules/login.module.yamljavascript: ./scripts/setup.jsRelative paths resolve from the YAML file containing the step, not from the
project root or importing test. Use ./... or ../...; do not use absolute
paths or ~. If you move, rename, or delete a referenced file, grep for the old
path and update every reference.
v1 YAML should still be edited only through MCP. Do not use file-backed
JavaScript in v1 YAML or MCP CLI step strings; v1 JavaScript steps should carry
executable code in code / --code. Use JavaScript file references only in
mobile v2 YAML.
Do not add internal or auto-generated fields to v2 YAML.
Gather only what you need:
For long tasks, inspect nearby mobile tests and modules before authoring. Reusing an existing module is usually better than rebuilding a common flow inline.
Ask before long-running checks, starting over from scratch, destructive actions, local device overrides, or editing a shared module.
If the user requests a specific workflow, respect it unless it is unsafe or impossible. Otherwise, use direct mobile v2 YAML editing when the file is v2, the change is localized, the step sequence is known, and live device discovery is not required. Good examples: reword an assertion, adjust a target, update an env key, fix a file reference, or insert a small known step from a nearby pattern.
Use the MCP device-validation workflow when the file is v1 or unknown, live UI state must be discovered, target timing is flaky, the flow is multi-step and unclear, the change depends on platform behavior, or the user asks to build/validate interactively.
Use momentic_test_create for new mobile tests; search for the tool if it is not
visible. It requires name, platform, and valid mobile settings. Only pass
folder/path fields when requested.
momentic_session_start requires an existing testId; it does not create
tests.
ELEMENT_CHECK or SCREEN_CHECK
for deterministic text/state, and AI_CHECK for semantic visual state.AI_CHECK is multimodal by default (screenshot + accessibility/XML
hierarchy). For a screenshot-only check, use its visual-only form (the
assertVisually YAML key). Reach for it when the hierarchy is unavailable or
unreliable, such as a WebView with multiple pages, or when the condition is
purely visual. The condition must be fully verifiable from the current
viewport, since no hierarchy and nothing offscreen is available.before / steps / after or setup / main / teardown
unless the test intent requires it.Mobile v2 is the human-editable format. Steps are compact: each step has one
top-level command key, such as tap: Continue, or a detailed map under that key.
Tests use before / steps / after; modules use steps. Durations are
always milliseconds. No visible step/command IDs.
Direct-edit loop:
fileType and platform.Common mistakes:
0..100 in v2 YAML or outside 0..1 in MCP
CLI-style step strings.SCROLL_TO --direction down
searches lower content; SWIPE --direction up moves the finger up and reveals
lower content.npx momentic-mobile lint validates mobile v2 schemas and file references. Run
it when you are unsure of syntax after edits or after moving/renaming referenced
files.
State refresh after disk edits:
momentic_test_get inspects persisted state; it does not refresh an active
session after disk edits.Use this for every v1 edit and for mobile v2 work that needs live discovery. The tool surface is shared; persistence differs: v1 uses splice, while v2 can use splice or direct YAML edit plus reload/restart.
momentic_get_artifacts(): project context, config path, cwd, tests, modules,
environments, available AVDs, available iOS simulators, and managed mobile
asset channels. Read only what you need.momentic_test_get({ testId | testPath }): inspect persisted mobile test
state. Before a session, this is useful. During an active session after
splicing, prefer the splice response or returnTest: true.momentic_module_recommend({ userRequest }): find reusable flows.momentic_module_get({ selector }): inspect module params, defaults, enums,
and steps. Selector is exactly one of { id }, { name }, or { path }.momentic_session_start({ testId, ... }): start a mobile session. It returns
metadata, the Step Authoring Guide artifact, active Test Content with session
step IDs, an initial screenshot, and installed-apps info. Required: testId.
Call it by itself, not in parallel with other MCP tools.remote; use local only when requested.provider, envName, localDeviceId, and
localAppPath.momentic_run_step({ sessionId, fromStep, toStep?, targetSection?, resetSession? }): run existing active-session steps. Use step IDs from Test
Content or splice responses, never raw YAML. Use parentStepIdChain: [] for
top-level steps. Responds with the full result if the run finishes within 30
seconds. Otherwise it responds with the stepRunnerId and currently
executing step while the run continues in the background. Poll
momentic_poll_runner for the result. Do not start multiple runs in the same
session at once unless you intentionally want overlap; overlapping runs share
emulator state and can race each other.momentic_poll_runner({ sessionId, stepRunnerId?, timeoutSeconds? }): reports
active runs, finished runs, and any newly finished results. Prefer passing the
stepRunnerId reported by momentic_run_step to scope the response to that
run. Pass timeoutSeconds (0-30, default 0) alongside stepRunnerId to wait
up to that long for that run to finish before responding. Poll this instead
of retrying momentic_run_step.momentic_run_step and resetSession: true on
the same sessionId; do not reset between every micro-edit.momentic_session_terminate({ sessionId }): terminate when done.Author MCP steps in checkpoint-sized chunks. Preview forward until a logical section works, then splice that checkpoint. Good checkpoints are natural mobile flow boundaries such as login complete, permission handled, form submitted, item created, or confirmation visible. Avoid splicing one step at a time unless each step is uncertain, risky, or affects shared module structure.
momentic_preview_step({ sessionId, step }): execute one mobile step without
persisting. It is stateful. If it returns CacheId, include
--cache-id <CacheId> when splicing that step. The response screenshot shows
device state after the step.momentic_get_session_state with returnBrowserState: true, then inspect the
emulator-state text or artifact for accessible names, visible text, XML nodes,
webview structure, screen bounds, and nearby structure.momentic_test_splice_steps({ sessionId, startIndex, deleteCount, steps, targetSection?, parentStepIdChain?, returnTest? }): insert, replace, or
delete steps and persist.returnTest: true, verify the returned structure before continuing.momentic_run_step.Sessions are live emulator/simulator processes. Screenshots and UI snapshots are
transient. If the screenshot does not show expected state after an action, call
momentic_get_session_state once more; the app may still be loading.
MCP tools may return artifact links under .momentic-mcp/.... Read linked files
only when needed:
envKey, JavaScript/API outputs, or dependent
env values.momentic_get_session_state returns serialized emulator state only with
returnBrowserState: true; screenshots are returned by default.preview_step and splice_steps use CLI-style strings:
--step-type <TYPE> [options]. The platform-specific Step Authoring Guide
returned by momentic_session_start is authoritative.
Common examples:
--step-type TAP --description "the Continue button"--step-type TYPE --description "Email field" --value "[email protected]" --clear-content--step-type AI_CHECK --assertion "the confirmation message is visible" --timeout-seconds 10--step-type SCROLL_TO --description "Settings" --direction down--step-type PRESS --key HOME--step-type MODULE --module-id <id> --inputs email=env.USER_EMAILSplice example:
{
"sessionId": "SESSION_ID",
"startIndex": 0,
"deleteCount": 0,
"steps": [
"--step-type TAP --description \"the Continue button\" --cache-id UUID_FROM_PREVIEW",
"--step-type AI_CHECK --assertion \"the next screen is visible\" --timeout-seconds 10"
],
"targetSection": "main"
}
For mobile conditionals, create the CONDITIONAL step with --assertion-type
and the matching assertion fields, then splice nested steps with
parentStepIdChain: [conditionalStepId].
Default to module-first for logical flows of 4+ steps such as login, permission
handling, setup, navigation inside the app, or checkout. Call
momentic_module_recommend, inspect strong candidates with momentic_module_get,
then decide module vs inline.
Modules cannot contain modules. Splicing a MODULE step inside a module fails.
Editing a shared module requires user confirmation. To modify a module through
MCP, replace the module step with a MODULE step carrying the needed metadata
flags: --parameters, --parameter-enum, --default-parameter,
--module-name, --module-description, --disabled. Keys in
defaultParameters and parameterEnums must exist in parameters.
Module inputs values are JavaScript fragments as strings. Quote string
literals, reference env as env.X, and respect enum constraints exactly.
momentic_get_session_state.momentic_get_session_state once more.AI_CHECK, SCREEN_CHECK, ELEMENT_CHECK, or a targeted
SCROLL_TO over generic WAIT.momentic_run_step with resetSession: true.--x-fraction / --y-fraction only when semantic targeting
is not available. In MCP CLI strings, fractions are 0..1.SCROLL_TO --direction down for lower content and
SCROLL_TO --direction up for earlier content. Use manual SWIPE when there
is no specific target or SCROLL_TO is not appropriate.saveAs / --env-key or
setVariable, and that the consuming syntax is env.X vs {{ env.X }}.platform and the Step Authoring Guide for
platform-specific command availability.npx claudepluginhub momentic-ai/skillsCreates, runs, and maintains Momentic E2E tests and modules (YAML files) using AI agents for browser automation. Supports caching, env context, and config overrides.
Automates mobile app testing on iOS and Android using Maestro MCP: launches apps, interacts with UI elements, captures screenshots, runs flows, collects evidence. Use to verify implementations before completion.
Writes and runs Maestro UI test flows for React Native apps. Covers test selection, timing rules, testID conventions, multi-device testing, network mocking, and store inspection.