Skip to content

docs: add FAQ page and native features question #979

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 2 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
33 changes: 33 additions & 0 deletions website/docs/FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
id: faq
title: FAQ
---

<details>
<summary>Can I test native features of React Native apps?</summary>

<br />
<p>Short answer: no.</p>

React Native Testing Library does not provide a full React Native runtime since that would require running on physical device
or iOS simulator/Android emulator to provision the underlying OS and platform APIs.

Instead of using React Native renderer, it simulates only the JavaScript part of its runtime by
using [React Test Renderer](https://reactjs.org/docs/test-renderer.html) while providing queries
and `fireEvent` APIs that mimick certain behaviors from the real runtime.

This approach has certain benefits and shortfalls. On the positive side:

- it allows testing most of the logic of regular React Native apps
- it allows running test on any OS supported by Jest, or other test runner, e.g. on CI
- it uses much less resources than full runtime simulation
- you can use Jest fake timers

The the negative side:

- you cannot test native features
- certain JavaScript features might not be perfectly simulated, but we are working on it

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.

</details>
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
'migration-v7',
'migration-v2',
'how-should-i-query',
'faq',
'eslint-plugin-testing-library',
],
Examples: ['react-navigation', 'redux-integration'],
Expand Down