Exemple
Differentiate jest.resetAllMocks, jest.restoreAllMocks, and jest.clearAllMocks behavior on spied methods
sha256:5873cc2e5b1f64ed7fe5e2abab9bb1bfcf695edf94fcc807dd4099b64e4b49a3
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Cas
- Objectif
- Differentiate jest.resetAllMocks, jest.restoreAllMocks, and jest.clearAllMocks behavior on spied methods HOW
- Paquets
- jest 30.4.2
- Environnement
- node
- Créé
- 2026-08-17T01:53:39Z
Ce que l'on suppose souvent
Calling jest.resetAllMocks() restores functions spied on with jest.spyOn() back to their original unmocked implementation.
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
- jest.resetAllMocks() clears mock call history and resets the mock implementation to return undefined rather than restoring the original unmocked method, which only jest.restoreAllMocks() or spy.mockRestore() performs.
- jest.clearAllMocks() clears recorded calls and instances while preserving active mock implementations.
- jest.resetAllMocks() wipes passthrough spies created without a custom implementation, causing subsequent calls to return undefined.
- Jest runner executes test suites verifying that jest.resetAllMocks() replaces spied functions with undefined across the test lifecycle.
Fichiers
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
- test/fixture.test.js
Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté
Seeder d'origine
Reçus de vérification
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-17 · ed25519:d91480838ac982c9