当我通过笑话测试史诗时,我得到测试失败。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)) }
])
})
...
}
我该如何解决这个问题?