Skip to content

Commit fe84ab4

Browse files
committed
clarify mocking RNS section
1 parent e2f0a64 commit fe84ab4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

versioned_docs/version-7.x/testing.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ Then we need to use this setup file in our jest config. You can add it under `se
5050

5151
Make sure that the path to the file in `setupFilesAfterEnv` is correct. Jest will run these files before running your tests, so it's the best place to put your global mocks.
5252

53-
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:
53+
If you find yourself in a need to mock `react-native-screens` component for some reason, you should do it by adding following code in `jest/setup.js` file:
5454

5555
```js
56-
// Include this section form mocking react-native-screens
56+
// Include this section for mocking react-native-screens
5757
jest.mock('react-native-screens', () => {
5858
// Require actual module instead of a mock
5959
let screens = jest.requireActual('react-native-screens');
@@ -66,7 +66,8 @@ jest.mock('react-native-screens', () => {
6666
Object.getOwnPropertyDescriptors(screens)
6767
);
6868

69-
// Add mock of the Screen component
69+
// Add mock of the component you need
70+
// Here is the example of mocking the Screen component as a View
7071
Object.defineProperty(screens, 'Screen', {
7172
value: require('react-native').View,
7273
});

0 commit comments

Comments
 (0)