使用Router测试react组件,createMemoryHistory发出警告

时间:2017-01-11 13:08:50

标签: reactjs react-router jestjs

在编写依赖于路由的组件的测试时:

const history = createMemoryHistory('/');
const wrapper = mount(<App history={history} />);

我收到大量警告:

(node:24823) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: Cannot read property 'history' of undefined
(node:24823) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:24823) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): TypeError: Cannot read property 'history' of undefined

我不知道如何消除它们。愿任何人帮忙吗?

我的应用将此history媒体资源转发至<Router />

0 个答案:

没有答案