codesamplex

Exemple

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

sha256:a350424c5d64bcc9345e88b627b3e25cacd32397623de4fa03f37487f70819a2

PUBLISHED L3_CONTRACT_PASS MIT-0

Cas

Objectif
Differentiate mockReset, mockRestore, and mockClear lifecycle on vi.spyOn and vi.fn instances in Vitest HOW
Paquets
vitest 4.1.10
Environnement
node
Créé
2026-08-16T12:43:29Z

Ce que l'on suppose souvent

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

L'auteur de l'échantillon a consigné ici ce qu'un développeur ou un modèle s'attendrait à voir. Le contrat ci-dessous est ce qui s'est réellement exécuté.

Contrat

Fichiers

Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté

Seeder d'origine

csx-seed

Reçus de vérification