-
Notifications
You must be signed in to change notification settings - Fork 275
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
Fix finding props with testId #357
Conversation
@fortmarek Does this mean that everything needs to be passed to ScrollComponent? It may not be feasible in cases where we're reimplementing an existing ScrollView prop. Is it possible to suggest an alternative instead? Can we change the query? |
The current behaviour is the expected one, so I don't think we can change the query. This test case inside the
I am actually not sure if I don't like the solution proposed in this PR - although it fixes the issue, we should not have to pass all the props of @linddominic, what do you think about this? |
Hm. I don't know if the statement that I could dig into if there is another way to write the same test too see if that particular test in Shop is doing something iffy. On a higher-level discussion if we want FlashList to be a drop-in replacement to FlashList I feel like this PR should get merged. |
This is a good point. We should probably get this merged as |
Is that really a good idea? If you pass all the props things will break for e.g, I don't have an issue with just passing FlatList can stop forwarding this prop too and I wouldn't call it a breaking change even if some people need to fix their tests. It's going to be extremely difficult to maintain FlashList if we can't change internals when we want to. Honestly, I'd only want to worry about keeping public APIs same. |
I generally agree but at least initially, people will expect
I think nobody is advocating for matching the internals completely or treating internals as a public API. We both agree that the way the test is written relies on the internal implementation which you never should do. But as mentioned, in this case we can accommodate Shop team as it should not really impact us in a negative way. |
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.
Based on the discussion regarding this change, I agree that it makes sense to merge it
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, including this has no side effects.
@linddominic this has now been released in the |
Description
Shop has had issues with triggering
onViewableItemsChanged
when getting theFlashList
instance viagetByTestId
from@testing-library/react-native
. TriggeringflatList.props.onViewableItemsChanged
returnedundefined
here.The reason for this is that
getByTestId
does not get youFlashList
component directly but whatever it renders as the last component. In our case, it'sScrollComponent
(see here).One possible fix (present in this PR) is to remove
onViewableItemsChanged
(which was unnecessary) from destructured props and pass it toProgressiveListView
which will in turn pass it toScrollComponent
. I have checked the failing test and now it correctly triggers the method.Reviewers’ hat-rack 🎩
Screenshots or videos (if needed)
Checklist