我在测试我的反应应用程序时遇到问题,错误说:TypeError: Cannot read property 'find' of undefined 这是代码:
beforeAll(() => {
wrapper = mount(<LoggedInLayout/>);
});
it('allows to set props', () => {
const username = 'testUser';
wrapper.setProps({username: username});
expect(wrapper.props().username).to.equal(username);
});
it('renders all subcomponents', () => {
expect(wrapper.find('ul.ant-menu')).to.have.lengthOf(2);
expect(wrapper.find('.ant-menu-item')).to.have.lengthOf(3);
expect(wrapper.find('button')).to.have.lengthOf(2);
expect(wrapper.find('.ant-input')).to.have.lengthOf(1);
expect(wrapper.find('.anticon')).to.have.lengthOf(2);
});