當我通過笑話測試史詩時,我得到測試失敗。jsdom:無法讀取null的屬性'_location'
Test Failed
/.../node_modules/jsdom/lib/jsdom/browser/Window.js:148
return idlUtils.wrapperForImpl(idlUtils.implForWrapper(window._document)._location);
TypeError: Cannot read property '_location' of null
at Window.get location [as location] (/.../node_modules/jsdom/lib/jsdom/browser/Window.js:148:79)
at Timeout.callback [as _onTimeout] (/.../node_modules/jsdom/lib/jsdom/browser/Window.js:525:40)
at ontimeout (timers.js:380:14)
at tryOnTimeout (timers.js:244:5)
at Timer.listOnTimeout (timers.js:214:5)
這是我的一些測試。我在fetchCategoriesEpic中使用了fetch()和promise。
it('test epic',() => {
...
const action$ = ActionsObservable.of({ type: FETCH_CATEGORIES })
fetchCategoriesEpic(action$)
.toArray() // collects everything in an array until our epic completes
.subscribe((actions) => {
expect(actions).toEqual([
{ type: FETCH_CATEGORIES },
{ type: FETCH_CATEGORIES_SUCCESS, payload: List(payload.data).map((category) => new Category(category)) }
])
})
...
}
我該如何解決這個問題?