Optional options: MockableOptionsOptional options: MockableOptionsCreates a snapshot-mocked copy of a plain object. The returned object has all methods wrapped for record/replay. The original object is not mutated.
import { mock, SnapshotStore } from '@biorate/unimock';
const obj = mock({ query: async (sql: string) => ({ data: [1] }) }, {
importMeta: import.meta,
});
await obj.query('SELECT 1'); // recorded or replayed
Description
Functional alternative to the
@Mockable()decorator. Returns the same class with prototype methods wrapped, without using decorator syntax.Example