-
-
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
feat: Added hostNodes method to ReactWrapper #1179
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great :-) can you please add it to ShallowWrapper
as well, along with tests and docs?
Going to add some tests tomorrow! |
</div>, | ||
); | ||
expect(wrapper.find('.foo').length).to.equal(2); | ||
expect(wrapper.find('.foo').hostNodes().length).to.equal(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we assert on the contents too, not just the length? something like:
const hostNodes = wrapper.find('.foo').hostNodes();
expect(hostNodes).to.have.lengthOf(1);
expect(hostNodes.is('div')).to.equal(true);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😩 I was trying to perform the PR trough the GitHub UI but I guess I'll have to clone the project locally 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the yarn.lock file; airbnb does not use yarn.
Sorry, it slipped in accidentally. Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending a rebase (ideally down to one commit), this LGTM
(if you need help rebasing, i'm happy to take care of it) |
I'm not sure if the rebase ended up well 🤔 |
b7efdca
to
06de273
Compare
Ok now it looks much better 😅 |
@FezVrasta still looks like there's a merge commit; would you like me to rebase it for you? |
aha, now it's good :-) |
Still, Travis doesn't look that happy... 🙄 |
</div>, | ||
); | ||
const hostNodes = wrapper.find('.foo').hostNodes(); | ||
expect(wrapper.find('.foo')).to.have.length(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe try lengthOf
instead of length
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other tests in the same page use .length
, why so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They should all be using lengthOf; it was just a thought about fixing the travis tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem to help
k, rebased, added some docs, and fixed the issue (it needs |
and finally, React 13 doesn't support SFCs; so the component in the tests needed to be class-based. |
#### Examples | ||
|
||
```jsx | ||
const wrapper = mount(<div><MyComponent className="foo" /><div className="foo" /></div>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be shallow
instead of mount
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, good catch! Want to submit a PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda critical for migration from v2 to v3. Not trying to rush, but I don't want to monkey patch this... so any plans on releasing this sooner than later? |
I think we're hoping to cut a release this week. |
@TheSharpieOne enzyme v3.1.0 was just published. enjoy. |
fixes #1174