Skip to main content
Creates a test snapshot: a self-contained .snapshot.zip that captures a test exactly as it would run right now, with modules expanded, step caches resolved, environment variables baked in, and the relevant project config frozen. A snapshot can later be replayed in complete isolation with momentic run --from-snapshot — no local test files, modules, environment, or cache backend required.
npx momentic snapshot checkout.test.yaml login.test.yaml
One zip is written per resolved test, named <testId>.snapshot.zip. Folders are expanded into the tests they contain, exactly like momentic run.

What a snapshot contains

Each zip holds two entries:
  • test.yaml — the resolved test: metadata plus the fully expanded ResolvedStep[] lists (before/main/after steps) with every step cache inlined.
  • metadata.json — readable fields (momenticVersion, schemaVersion, createdAt, relativeFilePath, environment name, base URL, and the frozen project config: browser, ai, advanced, retries).
Snapshots can only be replayed by the organization that created them, to prevent accidental leakage of environment secrets.

Arguments

<tests...>
array
required
One or more test file paths or folders on the local machine to snapshot. Pass multiple values separated by spaces. Folders are expanded into every test they contain.

Common flags

-c, --config <config>
string
Path to the Momentic configuration file. Defaults to momentic.config.yaml in the current directory.
-f, --filter <filter>
string
When using workspaces, load the project whose name matches the filter.
--output-dir <outputDir>
string
Directory to write the .snapshot.zip files to. Defaults to the current directory.
-y, --yes
boolean
Skip all confirmation prompts. Enabled by default when CI is set.

Environment

--env <env>
string
Environment to resolve when capturing the snapshot. Overrides any environment configured on the test itself. The resolved variables are frozen into the snapshot.
--url-override <urlOverride>
string
Override the base URL resolved into the snapshot. Useful for capturing a snapshot pointed at a specific deployment.

Caching

--regenerate-cache
boolean
Resolve every step cache from scratch instead of reusing existing caches before freezing them into the snapshot.
Steps are resolved without cached data, which significantly increases the time to create the snapshot.

Examples

Snapshot a single test into the current directory:
npx momentic snapshot checkout.test.yaml
Snapshot every test in a folder, writing the zips elsewhere:
npx momentic snapshot tests/smoke --output-dir ./snapshots
Snapshot a test resolved against a specific environment and deployment:
npx momentic snapshot checkout.test.yaml --env staging --url-override https://preview-123.example.com
Then replay any of the produced zips in isolation:
npx momentic run --from-snapshot ./snapshots/<testId>.snapshot.zip