Variable UnimockConst

Unimock: {
    flush: (() => void);
    release: ((className?) => void);
    resetStores: (() => void);
    get isRecord(): boolean;
    get isReplay(): boolean;
    get mode(): UnimockMode;
    get snapshotDir(): string;
} = ...

Type declaration

  • flush: (() => void)

    Description

    Flushes all dirty snapshot stores to disk.

      • (): void
      • Returns void

  • release: ((className?) => void)

    Description

    Releases a single snapshot store's in-memory data by class name. No-op when className is absent or no store is registered. Call between host test files to bound memory in a long-running worker (e.g. vitest isolate: false).

      • (className?): void
      • Parameters

        • Optional className: string

        Returns void

  • resetStores: (() => void)

    Description

    Releases all snapshot stores' in-memory data (clears the registry).

      • (): void
      • Returns void

  • get isRecord(): boolean

    Description

    Whether current mode is 'record'.

  • get isReplay(): boolean

    Description

    Whether current mode is 'replay'.

  • get mode(): UnimockMode

    Description

    Current operating mode. Reads the mutating SnapshotStore.mode (tracked by setMode), so it stays consistent with Unimock.isRecord / Unimock.isReplay after a runtime mode switch — unlike a static parse of the UNIMOCK env var.

  • get snapshotDir(): string

    Description

    Resolved snapshot directory path.

Description

Convenience namespace bundling the most common Unimock utilities.

Example

import { Unimock } from '@biorate/unimock';

console.log(Unimock.mode); // 'off' | 'record' | 'replay'
Unimock.flush(); // flush all snapshots