ReferenceError:ウィンドウが定義されていません。私はnestテストをjestで単体テストに実行するとこのエラーが出ます。エラーは、次のコードのエクスポート機能から発生します。誰もこのタイプのエラーに直面して解決しましたか?ReferenceError:ウィンドウが定義されていません。 jestでユニットテストにnpmテストを実行したときにこのエラーが発生しました
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from '../modules/rootReducer';
export function injectAsyncReducers(asyncReducers) {
const injectReducers = Object.keys(asyncReducers).reduce((all, item) => {
if (store.asyncReducers[item]) {
delete all[item];
}
return all;
}, asyncReducers);
store.asyncReducers = Object.assign({}, store.asyncReducers, injectReducers);
replaceReducers(rootReducer);
}
「redux」コードそのものh 'window'への参照はありません。あなたの 'rootReducer'はどのように見えますか? –
これは私のrootReducerファイルのコードimport {combineReducers} from 'redux'です。 '../reducers/fetchMenu'からのインポートメニュー。 '../reducers/chooseOrderType'からのインポートオーダータイプ。 '../reducers/fetchVendorInfo'からインポートベンダー。 エクスポートデフォルトcombineReducers({ メニュー、 ベンダー、 オーダータイプ }); – khalifathul