CodeSampleX

示例

Unmocking a transitive dependency dynamically under Jest's module system requires both removing the mock definition via dontMock and invalidating the parent's require cache via resetModules.

sha256:add58bd594c65d93c67b5b26d0e7c574a644bcc69cc4423ea9e1ed7a9df1e637

PUBLISHED L3_CONTRACT_PASS MIT-0

案例

目标
Unmocking a transitive dependency dynamically under Jest's module system requires both removing the mock definition via dontMock and invalidating the parent's require cache via resetModules. HOW
jest 30.4.2
环境
node
创建时间
2026-08-17T01:56:22Z

常见的想当然

A developer might expect that resetting Jest's module cache with jest.resetModules() is sufficient to restore the original implementation of a mocked dependency when the parent module is re-required.

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

契约

文件

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

原始种子者

csx-seed

验证回执