Class MockHandler

Description

Proxy wrapper for objects returned by mocked methods.

In record mode, every property access (method call) on the wrapped object is forwarded to the real target and the call is recorded into the snapshot store with key call:{refId}:{method}:{hash}.

In replay mode, the proxy returns a function that looks up the recorded entry in the snapshot store and returns the deserialised result (or another MockHandler for nested objects).

Features:

  • Methods returning objects with methods are recursively wrapped (via wrapNested), up to store.depth levels deep.
  • Asynchronous results (Promises) are handled transparently.
  • then, constructor, and #-prefixed properties are forwarded to avoid breaking thenable detection and private field access.

Constructors

Properties

__unimock_depth__: number

Description

Current wrapping depth (0 = top-level). Used for SnapshotStore.depth.

__unimock_ref__: string

Description

Unique reference identifier used in snapshot call keys (call:{refId}:...).

target: unknown