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

Add TestID to clickable part for e2e tests #43

Closed
gran33 opened this issue Oct 24, 2019 · 11 comments
Closed

Add TestID to clickable part for e2e tests #43

gran33 opened this issue Oct 24, 2019 · 11 comments

Comments

@gran33
Copy link

gran33 commented Oct 24, 2019

Is your feature request related to a problem? Please describe.
Yes.
I'm using Detox to e2e tests and Detox can't press on the link without TestID.

Describe the solution you'd like
Please add the ability to set TestID to the clickable component.
See RN docs for TestId: https://facebook.github.io/react-native/docs/view#testid

Describe alternatives you've considered
None.

Additional context
Thank you so much, you're awesome 😎

@obipawan
Copy link
Owner

Hi @gran33 thank you for the context 😄
could you suggest how'd you want to be able to pass down the TestID?
I could use some help with the design.

I was thinking something like so

<Hyperlink injectProps={ url => ({TestID: "testID for the given URL"}) }>
    ...
    ...
</Hyperlink>

@gran33
Copy link
Author

gran33 commented Dec 22, 2019

Hi @obipawan
I there any way to pass props to the clickable part of the hyperlink?
injectProps isn't self explanatory (sorry for the douchebaging 😏)
I think injectViewProps :)

WDYT?

@obipawan
Copy link
Owner

injectViewProps sounds good. Apart from the proposed injectViewProps, there isn't a way to pass props to a clickable component. So a func with url as the param and returning props sounds good?

obipawan pushed a commit that referenced this issue Dec 23, 2019
@obipawan
Copy link
Owner

Opened a PR #46
LMK if this seems good. I'll go ahead with a release if it's all good

@gran33
Copy link
Author

gran33 commented Dec 24, 2019

Hi, Thanks for the PR.
Why that?

there isn't a way to pass props to a clickable component

@obipawan
Copy link
Owner

This PR should solve that. You could pass props to a clickable component identified by the url

@gran33
Copy link
Author

gran33 commented Dec 24, 2019

Ok, sounds good.
As long as I can identify the clickable part by its testID

@obipawan
Copy link
Owner

Thanks @gran33
Just to clarify, you can pass props to the clickable part identified by the url it matched, like so,

<Hyperlink
  ...
  injectViewProps={ url => ({
        testID: url === 'some url' ? 'id1' : 'id2' ,
        style: url === 'some url' ? { color: 'red', fontSize: 20 } : { ... },
        //any other props you wish to pass to the component
  }) }
>
  ...
  ...
</Hyperlink>

@gran33
Copy link
Author

gran33 commented Dec 24, 2019

Amazing!
Thanks @obipawan

@obipawan
Copy link
Owner

Great. Then i'll merge this
Thanks for your help @gran33

obipawan added a commit that referenced this issue Dec 24, 2019
@obipawan
Copy link
Owner

Available on v0.0.19

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

No branches or pull requests

2 participants