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

Ensure components for react-native pass testID #3365

Merged
merged 1 commit into from
Jan 9, 2021
Merged

Ensure components for react-native pass testID #3365

merged 1 commit into from
Jan 9, 2021

Conversation

gauthamchandra
Copy link

@gauthamchandra gauthamchandra commented Jan 5, 2021

When developing for react native, components are sometimes marked with
the testID prop. This prop is functionally similar to the
data-testid attached for react web components.

Unfortunately, styled components for react native didn't pass this prop
down, making it difficult for react native test frameworks like Detox to
test.

This change fixes that so when a testID prop is specified for a styled
component for react-native, it is passed down to the corresponding
native component it represents.

NOTE: Since this only affects react-native, it ONLY makes a change to StyledNativeComponent

NOTE2: I was hoping to use this change in the next minor version (5.3.0) which is why I branched off legacy-v5. Hopefully that's alright.

For context:

@gauthamchandra
Copy link
Author

cc: @probablyup

CC'd you as you reviewed the previous attempt at this change

Hope that's ok 😅. Please tell me if I need to do anything else to get this PR to the finish line 😄 🙏🏼

Copy link
Contributor

@quantizor quantizor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a CHANGELOG entry please?

When developing for react native, components are sometimes marked with
the `testID` prop. This prop is functionally similar to the
`data-testid` attached for react web components.

Unfortunately, styled components for react native didn't pass this prop
down, making it difficult for react native test frameworks like Detox to
test.

This change fixes that so when a `testID` prop is specified for a styled
component for react-native, it is passed down to the corresponding
native component it represents
@gauthamchandra
Copy link
Author

Could you add a CHANGELOG entry please?

Done! Thanks again for the review!

@quantizor quantizor merged commit c14b039 into styled-components:legacy-v5 Jan 9, 2021
@gauthamchandra gauthamchandra deleted the legacy-v5 branch January 9, 2021 19:30
@gauthamchandra
Copy link
Author

@probablyup, any chance one of the core maintainers can cut a minor release 5.3.0 for this fix? We wanted to use this change in our codebases so it would be very much appreciated. 🙏🏼

@quantizor
Copy link
Contributor

quantizor commented Mar 30, 2021

@gauthamchandra this is now available as 5.2.2

If possible, could you make a tandem PR for master?

@gauthamchandra
Copy link
Author

gauthamchandra commented Apr 20, 2021

Sure thing. Will open one tonight 👍🏼 Thanks again!

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

Successfully merging this pull request may close these issues.

None yet

2 participants