-
Notifications
You must be signed in to change notification settings - Fork 274
docs: troubleshooting guilde #1065
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
id: troubleshooting | ||
title: Troubleshooting | ||
--- | ||
|
||
This guide describes common issues found by users when integrating React Native Test Library to their projects. | ||
|
||
## Matching React Native, React & React Test Renderer versions | ||
|
||
Check that you have matching versions of core dependencies: | ||
- React Native | ||
- React | ||
- React Test Renderer | ||
|
||
React Native uses different versioning scheme from React, you can use [React Native Upgrade Helper](https://react-native-community.github.io/upgrade-helper/) to find the correct matching between React Native & React versions. In case you use Expo, you should use dependency versions recommended by them and set by `expo upgrade` command. | ||
|
||
React Test Renderer usually has same major & minor version as React, as they are closely related and React Test Renderer is part of [React monorepo](https://github.com/facebook/react). | ||
|
||
Related issues: | ||
- [#1061](https://github.com/callstack/react-native-testing-library/issues/1061) | ||
- [#938](https://github.com/callstack/react-native-testing-library/issues/938) | ||
- [#920](https://github.com/callstack/react-native-testing-library/issues/920) | ||
|
||
## Example repository | ||
|
||
We maintain an [example repository](https://github.com/callstack/react-native-testing-library/tree/main/examples/basic) that showcases a modern React Native Testing Library setup with TypeScript, Jest Native, etc. | ||
|
||
In case something does not work in your setup you can refer to this repository for recommended configuration. | ||
|
||
## Act warnings | ||
|
||
When writing tests you may encounter warnings connected with `act()` function. There are two kinds of these warnings: | ||
|
||
* sync `act()` warning - `Warning: An update to Component inside a test was not wrapped in act(...)` | ||
* async `act()` warning - `Warning: You called act(async () => ...) without await` | ||
|
||
You can read more about `act()` function in our [understanding `act` function guide](https://callstack.github.io/react-native-testing-library/docs/understanding-act). | ||
|
||
Normally, you should not encounter sync `act()` warnings, but if that happens this probably indicate an issue with your test and should be investigated. | ||
|
||
In case of async `act()` function this might happen more or less randomly, especially if your components contain async logic. So far this warning does not seem to affect test correctness. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, never payed attention to the difference between those two.