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

[Docs]: add a guide for testing #8715

Open
sonicolasj opened this issue Mar 11, 2022 · 5 comments
Open

[Docs]: add a guide for testing #8715

sonicolasj opened this issue Mar 11, 2022 · 5 comments
Assignees
Labels

Comments

@sonicolasj
Copy link

What is the new or updated feature that you are suggesting?

Please add a testing guide to make it clear how to unit test components using react-router!

Why should this feature be included?

There was a testing guide for v5, which was very helpful!

@brophdawg11 brophdawg11 added docs and removed feature labels Jan 9, 2023
@brophdawg11 brophdawg11 changed the title [v6][Docs]: add a guide for testing [Docs]: add a guide for testing Jan 9, 2023
@ptim
Copy link

ptim commented Feb 27, 2023

Here's a guide from React Testing Library for v6:
https://testing-library.com/docs/example-react-router/

@github-actions
Copy link
Contributor

This issue has been automatically marked stale because we haven't received a response from the original author in a while 🙈. This automation helps keep the issue tracker clean from issues that are not actionable. Please reach out if you have more information for us or you think this issue shouldn't be closed! 🙂 If you don't do so within 7 days, this issue will be automatically closed.

@halcarleton
Copy link

Here's a guide from React Testing Library for v6: https://testing-library.com/docs/example-react-router/

This guide does not include instructions for testing data routes. I have tried to find a way to adapt the guide to work with data routes but have not had any success.

@maruhgar
Copy link

Here's a guide from React Testing Library for v6: https://testing-library.com/docs/example-react-router/

This guide does not include instructions for testing data routes. I have tried to find a way to adapt the guide to work with data routes but have not had any success.

I just submitted a PR after raising an issue . You can refer to this working example, which uses vite and vitest. It is the v6 example extended for v6.4 using createBrowserRouter and action and loader scenarios. Hope this helps.

@busticated
Copy link

busticated commented Mar 5, 2024

it would be super-helpful to have docs around testing components which invoke useFetcher() specifically. short of mocking it out entirely, i haven't had much luck sorting it out on my own.

edit: and useSubmit() too 😮‍💨

Error: useSubmit must be used within a data router.  See https://reactrouter.com/routers/picking-a-router.

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

No branches or pull requests

7 participants