Skip to content

Commit 6108b95

Browse files
docs: troubleshooting guilde (#1065)
1 parent bf44883 commit 6108b95

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ The [public API](https://callstack.github.io/react-native-testing-library/docs/a
143143

144144
## Troubleshooting
145145

146-
- [Understanding `act` function](https://callstack.github.io/react-native-testing-library/docs/understanding-act)
146+
- [Troubleshooting guide](https://callstack.github.io/react-native-testing-library/docs/troubleshooting)
147147

148148
## Related External Resources
149149

website/docs/Troubleshooting.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
id: troubleshooting
3+
title: Troubleshooting
4+
---
5+
6+
This guide describes common issues found by users when integrating React Native Test Library to their projects.
7+
8+
## Matching React Native, React & React Test Renderer versions
9+
10+
Check that you have matching versions of core dependencies:
11+
- React Native
12+
- React
13+
- React Test Renderer
14+
15+
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.
16+
17+
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).
18+
19+
Related issues:
20+
- [#1061](https://github.com/callstack/react-native-testing-library/issues/1061)
21+
- [#938](https://github.com/callstack/react-native-testing-library/issues/938)
22+
- [#920](https://github.com/callstack/react-native-testing-library/issues/920)
23+
24+
## Example repository
25+
26+
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.
27+
28+
In case something does not work in your setup you can refer to this repository for recommended configuration.
29+
30+
## Act warnings
31+
32+
When writing tests you may encounter warnings connected with `act()` function. There are two kinds of these warnings:
33+
34+
* sync `act()` warning - `Warning: An update to Component inside a test was not wrapped in act(...)`
35+
* async `act()` warning - `Warning: You called act(async () => ...) without await`
36+
37+
You can read more about `act()` function in our [understanding `act` function guide](https://callstack.github.io/react-native-testing-library/docs/understanding-act).
38+
39+
Normally, you should not encounter sync `act()` warnings, but if that happens this probably indicate an issue with your test and should be investigated.
40+
41+
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.

website/sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
'migration-v2',
1010
'how-should-i-query',
1111
'faq',
12+
'troubleshooting',
1213
'eslint-plugin-testing-library',
1314
'understanding-act',
1415
],

0 commit comments

Comments
 (0)