鉴于以下组件:用一个玩笑测试用例阵营阿波罗时“无法读取空的财产_location”
export function App() {
return withApollo(<BrowserRouter>
<MatchListRouteHandler />
</BrowserRouter>);
}
// MatchListRouteHandler
export const Query = addTypenameToDocument(gql`
query GetMatches {
matches {
id
}
}
`);
export default graphql(Query)(MatchListRouteHandler);
而且测试用例:
it('renders without crashing',() => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});
我收到以下错误,当Jest试图运行测试用例:
/home/dan/match-history-analyser/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] (/home/dan/Projects/match-history-analyser/node_modules/jsdom/lib/jsdom/browser/Window.js:148:79)
at Timeout.callback [as _onTimeout] (/home/dan/Projects/match-history-analyser/node_modules/jsdom/lib/jsdom/browser/Window.js:525:40)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)