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

検証レシート