2017-05-05 14 views
0

この部分をJestでテストしたいのですが、いくつか問題があります。Jestテストの "module"オブジェクトの値を変更してください

私は関数を呼び出す前に値を変更しようと試みてきました:

module.hot = { accept: jest.fn() } 
console.log(module.hot) // This print the assigned value 
... 
configureStore({ initialState, history }) 

module.hot値は、呼び出された関数で設定されていません。

const configureStore = ({ initialState, history }) => { 
... 
    console.log(module.hot) // This print "undefined" 
    if (module.hot) { 
    module.hot.accept('reducers',() => { 
     store.replaceReducer(reducers) 
    }) 
    } 
} 

Jestは特定の方法で 'モジュール'オブジェクトを管理しますか?

答えて

-1

グローバル名前空間に住んでいるmoduleあなたのモジュールで、その原因は、あなたがそこにそれを設定する必要が理由のthats:

global.module = {hot: jest.fn()} 
関連する問題