-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Parent() not working properly #1991
Comments
I have just tried the same code snippet with Enzyme 2.9.1 and React 15.6.1 and the results differ from what I posted above:
This is what I would expected from this sequence. |
So, first - use What happens to your expectations when you make that change? |
Thanks for clearing that up! html() vs debug() is not really the point here - actually I gave mount as an example above.
In the test, using Enzyme 3.8.0 and React 16.7.0, bottomMost.parent().children() is an empty array. That is the problem. It seems that whenever I go up one level, I loose all information on child nodes. If I call bottomMost.parent().debug(), it only prints how the parent's node, and not the children, which is also something I would not expect. |
(cc @sstern6) |
@ljharb looking into it |
Hello, I got the same behavior with you, this is my enzyme & react version: // devDep
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
// dep
"react": "^16.10.2",
"react-dom": "^16.10.2", class Foo extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="foo">
Bar
<div className="bar"></div>
</div>
);
}
} it('should get parent', function() {
const app = mount(<Foo />);
console.log(
app
.childAt(0)
.parent()
.html(),
);
// outputs null
}); |
Hi, this is a demo for reproducing: https://github.com/upupming/enzyme-parent-bug, I have also commented on #1230 |
Current behavior
I have tried to create a couple of tests to a very simple React component.
Foo.js
Foo-test.js
It seems that when I try to access the parent element of the child node, I loose a lot of information. Basically html() and text() will output null, and childrens are gone.
Expected behavior
I would expect that the Wrapper returned by invoking parent() would be a fully fledged ReactWrapper with all children below (as if I was accessing it via the Wrapper returned by mount).
Your environment
JSDOM
API
Version
| enzyme 3.8.0
| react 16.7.0
| react-dom 16.7.0
Adapter
The text was updated successfully, but these errors were encountered: