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

.children() does not return text nodes when using mount #2265

Closed
2 of 13 tasks
hahnbi opened this issue Oct 18, 2019 · 1 comment · Fixed by #2269
Closed
2 of 13 tasks

.children() does not return text nodes when using mount #2265

hahnbi opened this issue Oct 18, 2019 · 1 comment · Fixed by #2269

Comments

@hahnbi
Copy link

hahnbi commented Oct 18, 2019

Current behavior

When calling .children() while using mount(), text nodes are not present in the result.

Expected behavior

When calling .children() while using mount(), text nodes are present in the result (similar to when using shallow()).

Codesandbox: https://codesandbox.io/s/stupefied-hodgkin-1d8gg, see index.test.js

Your environment

API

  • shallow
  • mount
  • render

Version

library version
enzyme 3.9
react 16.8.6
react-dom 16.8.6
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 ( )
@hahnbi
Copy link
Author

hahnbi commented Oct 21, 2019

After doing some code exploration, I see that .children() on ShallowWrapper doesn't automatically filter out any nodes:
https://github.com/airbnb/enzyme/blob/9e26937c12a46c9915327d913b2a9fd3e711476e/packages/enzyme/src/ShallowWrapper.js#L1222-L1224

...while on ReactWrapper, it filters out non-object nodes:
https://github.com/airbnb/enzyme/blob/9e26937c12a46c9915327d913b2a9fd3e711476e/packages/enzyme/src/ReactWrapper.js#L767-L769

Does anyone know what the intention is behind filtering out these children nodes?

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

Successfully merging a pull request may close this issue.

2 participants