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

検証レシート