-
Notifications
You must be signed in to change notification settings - Fork 2
feat(native): Add toContainElement() #146
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
base: feat/native-to-be-visible
Are you sure you want to change the base?
feat(native): Add toContainElement() #146
Conversation
.toHaveMessage("Expected element <View ... /> to contain element <Text ... />."); | ||
}); | ||
}); | ||
}); |
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 please add some tests for when there are no child nor parent elements 🙏
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.
Thanks for the recommendation! To take this into account, I've changed the structure of the tests so they're clearer and easier to read 🚀
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.
Nice work @kdquistanchala !
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 good so far. I left a few comments. Let me know if you have any questions 🙂
} | ||
|
||
return ( | ||
parentElement.findAll( |
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.
You can use the .some()
method instead of finding all elements and then checking if the length is > 0 🙂
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.
@JoseLion .some
does not exist on ReactInstance class. It is not an array
<View testID="grandParentId"> | ||
<View testID="parentId"> | ||
<View testID="childId" /> | ||
</View> | ||
<Text testID="textId" /> | ||
</View>, |
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.
Can we use <Text>
elements so that we can avoid the testIDs?
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.
Im trying to do this, but im not getting good results, would you like to pair?
describe (".toContainElement", () => { | ||
const element = render( |
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.
As a good practice, elements should be rendered on each test it(..)
function, so the cleanup function cleans what's rendered before each test, avoid flaky tests, etc.
35e5052
to
82fa78b
Compare
1942629
to
4194055
Compare
4cfe69c
to
dcded59
Compare
4194055
to
392d9c6
Compare
This PR adds the
toContainElement()
matcher for React Native