@@ -154,25 +154,25 @@ Let's a [`AppNavigator.test.js`](https://github.com/callstack/react-native-testi
154
154
``` jsx
155
155
import React from ' react' ;
156
156
import { NavigationContainer } from ' @react-navigation/native' ;
157
- import { render , fireEvent , cleanup } from ' react-native-testing-library' ;
157
+ import { render , fireEvent } from ' react-native-testing-library' ;
158
158
159
159
import AppNavigator from ' ../AppNavigator' ;
160
160
161
161
// Silence the warning https://github.com/facebook/react-native/issues/11094#issuecomment-263240420
162
162
jest .mock (' react-native/Libraries/Animated/src/NativeAnimatedHelper' );
163
163
164
164
describe (' Testing react navigation' , () => {
165
- test (' page contains the header and 10 items' , () => {
165
+ test (' page contains the header and 10 items' , async () => {
166
166
const component = (
167
167
< NavigationContainer>
168
168
< AppNavigator / >
169
169
< / NavigationContainer>
170
170
);
171
171
172
- const { getByText , getAllByText } = render (component);
172
+ const { findByText , findAllByText } = render (component);
173
173
174
- const header = getByText (' List of numbers from 1 to 20' );
175
- const items = getAllByText (/ Item number/ );
174
+ const header = await findByText (' List of numbers from 1 to 20' );
175
+ const items = await findAllByText (/ Item number/ );
176
176
177
177
expect (header).toBeTruthy ();
178
178
expect (items .length ).toBe (10 );
@@ -185,12 +185,12 @@ describe('Testing react navigation', () => {
185
185
< / NavigationContainer>
186
186
);
187
187
188
- const { getByText } = render (component);
189
- const toClick = getByText (' Item number 5' );
188
+ const { findByText } = render (component);
189
+ const toClick = await findByText (' Item number 5' );
190
190
191
191
fireEvent (toClick, ' press' );
192
- const newHeader = getByText (' Showing details for 5' );
193
- const newBody = getByText (' the number you have chosen is 5' );
192
+ const newHeader = await findByText (' Showing details for 5' );
193
+ const newBody = await findByText (' the number you have chosen is 5' );
194
194
195
195
expect (newHeader).toBeTruthy ();
196
196
expect (newBody).toBeTruthy ();
0 commit comments