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

Improve docs for async utils #625

Open
kentcdodds opened this issue May 22, 2021 · 4 comments
Open

Improve docs for async utils #625

kentcdodds opened this issue May 22, 2021 · 4 comments
Labels
docs Changes to the documentation enhancement New feature or request good first issue Good for newcomers

Comments

@kentcdodds
Copy link
Member

What is your question:

I'm sorta ashamed to admit it, but it's unclear to me how to use the async utils based on the docs. I've had to dig around a lot to figure it out. Could there be a few code examples added to the docs?

@kentcdodds kentcdodds added the question Further information is requested label May 22, 2021
@kentcdodds
Copy link
Member Author

Oh, and to be clear, the trouble is that I assumed that the async utils would be available as direct imports like they are in React Testing Library. Is there a reason they're not?

@mpeyper
Copy link
Member

mpeyper commented May 23, 2021

There is a code example in the async section but I'll admit it doesn't cover all of them and could be improved, especially as the only other reference for where to get them is merely implied by the heading hierarchy of the API reference.

I actually want to redo the docs as I feel the "story" it tries to tell as the hook requirements evolve actually just over-complicates the examples.

As for why it isn't a global import, the main reason is that unlike dom-testing-library we don't have a global object the keep track of the state of the hook (i.e., the DOM). In our world, the component with the state is only created when renderHook is called. We could have hoisted the component into the global space and made the utils work there too, but I worried that could impede concurrent testing (I may be off base on this) and was just additional effort I wanted to avoid. Honestly, I always found it a little jarring that they were global imports in RTL, but didn't take any context as to which render call I wanted to wait for.

I'm happy to consider moving them if a strong enough argument can be made.

@kentcdodds
Copy link
Member Author

I think simply adding some more complete examples to the API docs would be all that's needed.

@mpeyper mpeyper changed the title Use of async utils is unclear. Not exporting async utils directly? Improve docs for async utils May 24, 2021
@mpeyper mpeyper added docs Changes to the documentation enhancement New feature or request good first issue Good for newcomers and removed question Further information is requested labels May 24, 2021
@mpeyper
Copy link
Member

mpeyper commented May 24, 2021

Thanks for the input @kentcdodds, we'll look to improve the docs for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Changes to the documentation enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants