Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find descendants from .parent() #1876

Open
2 of 13 tasks
Zeroster opened this issue Oct 25, 2018 · 1 comment
Open
2 of 13 tasks

Cannot find descendants from .parent() #1876

Zeroster opened this issue Oct 25, 2018 · 1 comment

Comments

@Zeroster
Copy link

Current behavior

describe('Parent test', () => {
  it('should return a parent that can find things', () => {
    class MockComponent extends React.Component {
      render() {
        return (
            <div className="container">
              <div className="foo">Some foo</div>
              <div className="bar">Some bar</div>
            </div>
        );
      }
    }

    const wrapper = shallow(<MockComponent />);

    // The following passes on v3
    expect(wrapper.find('.foo').parents().find('.bar')).toExist();
    // The following fails on v3 but passes on v2
    expect(wrapper.find('.foo').parent().find('.bar')).toExist();
  });
});

Expected behavior

The following use case should pass:

expect(wrapper.find('.foo').parent().find('.bar')).toExist();

Your environment

API

  • shallow
  • mount
  • render

Version

library version
enzyme 3.7.0
react 16.6.0, 16.5.0
react-dom 16.6.0, 16.5.0
react-test-renderer 16.6.0, 16.5.0
adapter (below)

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-16.3
  • enzyme-adapter-react-16.2
  • enzyme-adapter-react-16.1
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )
@sstern6
Copy link
Contributor

sstern6 commented Feb 3, 2019

Related to #1916. Working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants