0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Jest】mockClear()・mockReset()・mockRestore()の違い

Last updated at Posted at 2021-06-24

mockClear()

  • mockFn.mock.callsmockFn.mock.instances の配列に格納されている全ての情報をリセットする

mockReset()

  • mockFn.mock.callsmockFn.mock.instances の配列に格納されている全ての情報をリセットする
  • モックされた戻り値と実装を削除する

mockRestore()

  • モック関数を利用していたものを本物のモジュールに戻す
  • jest.spyOn() でモック化したモジュールにのみ使用可能
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?