> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# momentic snapshot

> Freeze tests into self-contained zips for fully isolated replay.

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
included, environment variables baked in, and the relevant project config
frozen. A snapshot can later be replayed in complete isolation with
[`momentic run --from-snapshot`](/cli-reference/momentic/commands/run#snapshots)
(no local test files, modules, environment, or cache backend required).

```bash theme={null}
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`](/cli-reference/momentic/commands/run).

## What a snapshot contains

Each zip holds two entries:

* `test.yaml` - the resolved test: metadata plus the fully expanded before,
  main, and 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`).

<Note>
  Snapshots can only be replayed by the organization that created them, to
  prevent accidental leakage of environment secrets.
</Note>

## Arguments

<ParamField path="<tests...>" type="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.
</ParamField>

## Common flags

<ParamField path="-c, --config <config>" type="string">
  Path to the Momentic configuration file. Defaults to `momentic.config.yaml` in
  the current directory.
</ParamField>

<ParamField path="-f, --filter <filter>" type="string">
  When using [workspaces](/configuration/workspace), load the project whose name
  matches the filter.
</ParamField>

<ParamField path="--output-dir <outputDir>" type="string">
  Directory to write the `.snapshot.zip` files to. Defaults to the current
  directory.
</ParamField>

<ParamField path="-y, --yes" type="boolean">
  Skip all confirmation prompts. Enabled by default when `CI` is set.
</ParamField>

## Environment

<ParamField path="--env <env>" type="string">
  Environment to resolve when capturing the snapshot. Overrides any environment
  configured on the test itself. The resolved variables are frozen into the
  snapshot.
</ParamField>

<ParamField path="--url-override <urlOverride>" type="string">
  Override the base URL resolved into the snapshot. Useful for capturing a
  snapshot pointed at a specific deployment.
</ParamField>

## Examples

Snapshot a single test into the current directory:

```bash theme={null}
npx momentic snapshot checkout.test.yaml
```

Snapshot every test in a folder, writing the zips elsewhere:

```bash theme={null}
npx momentic snapshot tests/smoke --output-dir ./snapshots
```

Snapshot a test resolved against a specific environment and deployment:

```bash theme={null}
npx momentic snapshot checkout.test.yaml --env staging --url-override https://preview-123.example.com
```

Then replay one or more of the produced zips in isolation:

```bash theme={null}
npx momentic run --from-snapshot ./snapshots/checkout.snapshot.zip ./snapshots/login.snapshot.zip
```
