我无法为withrouter包装的组件编写测试用例。我将测试用例写为
it('should render all subpageHeader details', () => {
const { queryByText } = render(
<Router history={mockHistory}>
<SubPageHeader {...defaultProps} />
</Router>
);
const backText = queryByText('Go back to reservation details');
expect(backText).toBe({});
})
并将组件导出为
export default withRouter(SubPageHeader);
我无法使用queryByText
从组件中获取文本。我遇到错误
received value must be an HTMLElement or an SVGElement.
Received has value: null
任何人请给我一个解决方案