Reputation: 37
I have a problem testing my react app the bug says: TypeError: Cannot read property 'find' of undefined This is the code:
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);
});
Upvotes: 0
Views: 210