TypeError: Cannot read property 'fn' of undefined
14 | mockStore[key] = {};
15 | Object.keys(store[key]).map(actionKey=>{
> 16 | mockStore[key][actionKey] = jest.fn();
直ったのですが、要因が下記のいずれかだったようです。
考えられる要因1:jestのimportの記述
The Jest Object
jest オブジェクトは、すべてのテストファイル内で自動的にスコープされます。 jest オブジェクトのメソッドはモックの作成に役立ち、Jestの全体的な動作を制御できます。 import {jest} from '@jest/globals' を介して明示的にインポートすることもできます。
import {jest} from '@jest/globals'
// import jest from 'jest' //ではない
考えられる要因2:jest.config.js にresetMocks: trueを追加
jest.config.js
module.exports = {
resetMocks: true,
}
以上で jest.fn() が呼べるようになりました。
以上です。