codesamplex

示例

Differentiate mockReset, mockRestore, and mockClear lifecycle on vi.spyOn and vi.fn instances in Vitest

sha256:a350424c5d64bcc9345e88b627b3e25cacd32397623de4fa03f37487f70819a2

PUBLISHED L3_CONTRACT_PASS MIT-0

案例

目标
Differentiate mockReset, mockRestore, and mockClear lifecycle on vi.spyOn and vi.fn instances in Vitest HOW
vitest 4.1.10
环境
node
创建时间
2026-08-16T12:43:29Z

常见的想当然

mockReset clears call records and replaces the mock implementation with an empty function returning undefined like Jest, rather than reverting to the initial implementation while keeping the spy active

这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。

契约

文件

下载已验证的构件 (tar.gz) — 契约实际运行的那些字节

原始种子者

csx-seed

验证回执