CodeSampleX

示例

jest.doMock registered inside jest.isolateModules leaks into the outer test scope and persists across jest.resetModules.

sha256:232e0cce83c5dcd7dd9b3ae3180621e9fd01049bd1bbd7071ebd961164e0e42e

PUBLISHED L3_CONTRACT_PASS MIT-0

案例

目标
jest.doMock registered inside jest.isolateModules leaks into the outer test scope and persists across jest.resetModules. HOW
jest 30.4.2
环境
node
创建时间
2026-08-17T01:55:00Z

常见的想当然

jest.isolateModules isolates module mocking performed with jest.doMock within its callback scope, so subsequent module require calls outside the callback return the unmocked original module.

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

契约

文件

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

原始种子者

csx-seed

验证回执