Skip to content

Commit 597fa3c

Browse files
docs: add FAQ page and native features question (#979)
* docs: add FAQ page and native features question * docs: fixed grammar issues & added native examples
1 parent 3e9fdd5 commit 597fa3c

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

website/docs/FAQ.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
id: faq
3+
title: FAQ
4+
---
5+
6+
<details>
7+
<summary>Can I test native features of React Native apps?</summary>
8+
9+
<br />
10+
<p>Short answer: no.</p>
11+
12+
React Native Testing Library does not provide a full React Native runtime since that would require running on physical device
13+
or iOS simulator/Android emulator to provision the underlying OS and platform APIs.
14+
15+
Instead of using React Native renderer, it simulates only the JavaScript part of its runtime by
16+
using [React Test Renderer](https://reactjs.org/docs/test-renderer.html) while providing queries
17+
and `fireEvent` APIs that mimick certain behaviors from the real runtime.
18+
19+
This approach has certain benefits and shortfalls. On the positive side:
20+
21+
- it allows testing most of the logic of regular React Native apps
22+
- it allows running test on any OS supported by Jest, or other test runner, e.g. on CI
23+
- it uses much less resources than full runtime simulation
24+
- you can use Jest fake timers
25+
26+
The the negative side:
27+
28+
- you cannot test native features
29+
- certain JavaScript features might not be perfectly simulated, but we are working on it
30+
31+
For instance, [react-native's ScrollView](https://reactnative.dev/docs/scrollview) has several props that depend on native calls. While you can trigger `onScroll` call with `fireEvent.scroll`, `onMomentumScrollBegin` is called from the native side and will therefore not be called.
32+
33+
</details>

website/sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
'migration-v7',
88
'migration-v2',
99
'how-should-i-query',
10+
'faq',
1011
'eslint-plugin-testing-library',
1112
],
1213
Examples: ['react-navigation', 'redux-integration'],

0 commit comments

Comments
 (0)