Class SnapshotStore

Description

Per-class snapshot store that manages loading, recording, and persisting snapshot data.

Each decorated class gets its own SnapshotStore instance, cached by className + snapshotDir. The store is shared across all instances of the decorated class within the same process.

Features:

  • Automatic gzip detection and compression (UNIMOCK_GZIP=1).
  • String pooling: strings >500 B are deduplicated into a shared dictionary within the file.
  • Transparent de-pooling on read — replay code never sees pooled_string entries.

Implements

  • SnapshotStoreEntry

Constructors

  • Parameters

    • className: string

      class name used for the snapshot filename

    • Optional snapshotDir: string

      optional directory override

    • Optional importMeta: ImportMeta

      pass import.meta from calling module to resolve snapshot dir relative to it

    Returns SnapshotStore

Properties

className: string

Description

Name of the mocked class (from Base.name).

depth: number = Infinity

Description

Maximum nested wrapping depth (default: Infinity). Set by @Mockable({ depth }).

dirty: boolean = false
poolCounter: number = 0
snapshotPath: string

Description

Absolute path to the snapshot file on disk.

stringPool: Map<string, string>
symbols: boolean = false

Description

Enable symbol serialization (default: false). Set by @Mockable({ symbols: true }).

_mode: UnimockMode = ...

Accessors

Methods