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

feat: add renderHook function #923

Merged
merged 4 commits into from
Apr 26, 2022

Conversation

pierrezimmermannbam
Copy link
Collaborator

Summary

This pr provides a basic implementation of renderHook as requested in #869. The solution is almost a copy past from the one made in react testing library

Test plan

Some test cases were added, also inspired from the implementation from react testing library

@AugustinLF
Copy link
Collaborator

The @testing-library/react PR still hasn't been merged, so I'd like for it to be merged first before getting that in. I'm monitoring said PR, but don't hesitate to ping me once it's merged if I miss it.

@mpeyper
Copy link
Contributor

mpeyper commented Apr 15, 2022

The RTL PR has been merged now. Please let me know if there is anything I can do to progress this.

@AugustinLF AugustinLF self-requested a review April 19, 2022 13:54
Copy link
Collaborator

@AugustinLF AugustinLF left a comment

Choose a reason for hiding this comment

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

Implementation and tests look correct to me. Could you fix the conflicts and also add documentation for it please?

https://github.com/callstack/react-native-testing-library/blob/main/website/docs/API.md

After that I think we should be able to get that in!

@pierrezimmermannbam pierrezimmermannbam force-pushed the implementRenderHook branch 2 times, most recently from 8153480 to 01b9468 Compare April 19, 2022 17:07
@pierrezimmermannbam
Copy link
Collaborator Author

I'm working on migrating to typescript, I'll add documentation afterwards, it shouldn't take long

@pierrezimmermannbam
Copy link
Collaborator Author

It's done, there is a typing issue because the option param is optional so initialProps may not be defined when it needs to be but changing the typing would mean having a different api from the one of react-hooks-testing-library and I'm not sure it's something we want.

I also added documentation, I used the documentation I found on the react-hooks-testing-library repo and added some examples

@AugustinLF
Copy link
Collaborator

Oops forgot to ask for flow types https://github.com/callstack/react-native-testing-library/blob/main/typings/index.flow.js But after that we should be good I believe

@pierrezimmermannbam
Copy link
Collaborator Author

@AugustinLF I added the flow types

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.

Pushed some documentation updates. Looks pretty!

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

Successfully merging this pull request may close these issues.

4 participants