The Wayback Machine - https://web.archive.org/web/20200614083103/https://github.com/enzymejs/enzyme/issues/2351
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

[Docs] ShallowWrapper/closest docs have an incorrect example #2351

Open
douglasnaphas opened this issue Mar 12, 2020 · 1 comment
Open

[Docs] ShallowWrapper/closest docs have an incorrect example #2351

douglasnaphas opened this issue Mar 12, 2020 · 1 comment

Comments

@douglasnaphas
Copy link

@douglasnaphas douglasnaphas commented Mar 12, 2020

The example at ShallowWrapper/closest seems to be out of date.

The example is:

const wrapper = shallow(<MyComponent />);
expect(wrapper.find(Foo).closest('.bar')).to.have.lengthOf(1);

This does not make any sense, as there is no Foo in the wrapper.

API

  • shallow
  • mount
  • render

Version

library version
enzyme
react
react-dom
react-test-renderer
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 ( )
@douglasnaphas
Copy link
Author

@douglasnaphas douglasnaphas commented Mar 12, 2020

Actually it looks like the components rendered for testing in other docs examples have been replaced with <MyComponent /> in contexts where this does not make sense: https://enzymejs.github.io/enzyme/docs/api/ShallowWrapper/findWhere.html.

const wrapper = shallow(<MyComponent />);
const complexComponents = wrapper.findWhere((n) => n.type() !== 'string');
expect(complexComponents).to.have.lengthOf(8);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.