Skip to content

Instantly share code, notes, and snippets.

@Kage0x3B
Kage0x3B / create-mock.util.ts
Created February 27, 2024 15:01
Vitest createMock similar to @golevelup/ts-jest's createMock
import { vi } from 'vitest';
import type { MockInstance, ArgumentsType } from 'vitest';
type DeepPartial<T> = {
[P in keyof T]?: T[P] extends Array<infer U>
? Array<DeepPartial<U>>
: T[P] extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: unknown extends T[P]
? T[P]