Skip to content

feat: add getAllByTestId and queryAllByTestId queries #198

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

Merged

Conversation

OzzieOrca
Copy link
Contributor

Summary

Implements getAllByTestId and queryAllByTestId queries.
Closes #186, Resolves #161

Test plan

I wrote a test and added two <Text> components to the component under test as a simple, contrived example. If you want me to think of a more realistic use case or you want to suggest one I'd be happy to try that. Maybe buttons in a loop or a child component or something. But I don't want to add complexity to the example component.

mzdunek93 and others added 2 commits July 2, 2019 21:28
- Filter out intermediate components in getAllByTestId. testIDs may be passed down to child components and appearing multiple times in the render tree. Some React Native components render multiple anyways. <Text> is an example.
Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Awesome! Can you also update the TypeScript types and tests?

@OzzieOrca
Copy link
Contributor Author

Just noticed flow is yelling at me. Ya I'll look at the TS types. Forgot about them...

@OzzieOrca
Copy link
Contributor Author

You have any suggestions for fixing the flow error? I'm not very familiar with flow. Seems like it doesn't know that instance.findAllByProps returns ReactTestInstance[].

@thymikee
Copy link
Member

thymikee commented Jul 3, 2019

You'll need too add a type annotation to filter that it returns a single ReactTestInstance, something like filter<ReactTestInstance>()

@OzzieOrca
Copy link
Contributor Author

That is a very unhelpful error telling you to specify a return type. I tried something like that and it wasn't happy...

@thymikee
Copy link
Member

thymikee commented Jul 3, 2019

@OzzieOrca
Copy link
Contributor Author

Didn't realize what that was doing...

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

It's a smoke test to make sure TS works :)

@thymikee thymikee merged commit fead652 into callstack:master Jul 3, 2019
@thymikee
Copy link
Member

thymikee commented Jul 3, 2019

Thank you so much!

@OzzieOrca OzzieOrca deleted the getAllByTestId-queryAllByTestId branch July 3, 2019 09:56
@OzzieOrca
Copy link
Contributor Author

Any chance you could create a release for this? I could pin it to a master commit for a while but I'd rather be done with it. But I realize you probably don't want a new release for every little thing. Do what you need to.

@thymikee
Copy link
Member

thymikee commented Jul 3, 2019

We'll publish it tomorrow :)

@thymikee
Copy link
Member

thymikee commented Jul 4, 2019

Released 1.10

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.

getAllByTestId is missing
3 participants