Skip to content

docs: refactor react-navigation example with React Nav team feedback #1253

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
merged 4 commits into from
Dec 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update examples/react-navigation/README.md
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
  • Loading branch information
mdjastrzebski and thymikee authored Dec 8, 2022
commit f58e4c779d005c69f655d83341001cda1c1a468d
2 changes: 1 addition & 1 deletion examples/react-navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ There are two types of recommeded tests:

## Non-recommended tests

There also exists another popular type of screen level tests, where users mock React Navigation objects like `navigation`, `route` and/or hooks like `useNavigation`, etc. This type is not recommended by the React Navigation team as it leads to fragile tests that can lead to false positive and false negative result. While the recommended approach is arguable harder it should lead to more robust tests helping to properly identify potential issues in test.
There also exists another popular type of screen level tests, where users mock React Navigation objects like `navigation`, `route` and/or hooks like `useNavigation`, etc. We don't recommend this way of testing. **Mocking internal parts of the libraries is effectively testing implementation details, which goes against the Testing Library's [Guiding Principles](https://testing-library.com/docs/guiding-principles/)**.

> Note that this example applies `includeHiddenElements: false` by default, so all queries will ignore elements on the hidden screens, e.g. inactive tabs or screens present in stack navigators. This option is enabled in `jest-setup.js` file, using `defaultIncludeHiddenElements: false` option to `configure` function.