You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: versioned_docs/version-7.x/testing.md
+126-9Lines changed: 126 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ Then we need to use this setup file in our jest config. You can add it under `se
48
48
49
49
Make sure that the path to the file in `setupFiles` is correct. Jest will run these files before running your tests, so it's the best place to put your global mocks.
50
50
51
-
If your configuration works correctly, you can skip this section, but in some unusual cases you will need to mock `react-native-screens` as well. To do so add the following code in `jest/setup.js` file:
51
+
If your configuration works correctly, you can skip this section, but in some unusual cases you will need to mock `react-native-screens` as well. To add mock of the particular component, e.g. `Screen`, add the following code in `jest/setup.js` file:
52
52
53
53
```js
54
54
// Include this section form mocking react-native-screens
@@ -74,13 +79,52 @@ If you're not using Jest, then you'll need to mock these modules according to th
74
79
75
80
We recommend using [React Native Testing Library](https://callstack.github.io/react-native-testing-library/) along with [`jest-native`](https://github.com/testing-library/jest-native) to write your tests.
76
81
77
-
We are going to write example tests illustrating the difference between `navigate` and `push` functions using Root Navigator defined below:
82
+
We are going to write example tests illustrating the difference between `navigate` and `push` functions using `RootNavigator` defined below:
For writing tests that include times functions you will need to use [Fake Timers](https://jestjs.io/docs/timer-mocks). They will replace times function implementation to use time from the fake clock.
224
300
225
-
Let's add another button to the Profile screen which uses `setTimeout`:
301
+
Let's add another button to the Profile screen, which uses `setTimeout`:
0 commit comments