@@ -154,25 +154,25 @@ Let's a [`AppNavigator.test.js`](https://github.com/callstack/react-native-testi
154154``` jsx
155155import React from ' react' ;
156156import { NavigationContainer } from ' @react-navigation/native' ;
157- import { render , fireEvent , cleanup } from ' react-native-testing-library' ;
157+ import { render , fireEvent } from ' react-native-testing-library' ;
158158
159159import AppNavigator from ' ../AppNavigator' ;
160160
161161// Silence the warning https://github.com/facebook/react-native/issues/11094#issuecomment-263240420
162162jest .mock (' react-native/Libraries/Animated/src/NativeAnimatedHelper' );
163163
164164describe (' Testing react navigation' , () => {
165- test (' page contains the header and 10 items' , () => {
165+ test (' page contains the header and 10 items' , async () => {
166166 const component = (
167167 < NavigationContainer>
168168 < AppNavigator / >
169169 < / NavigationContainer>
170170 );
171171
172- const { getByText , getAllByText } = render (component);
172+ const { findByText , findAllByText } = render (component);
173173
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/ );
176176
177177 expect (header).toBeTruthy ();
178178 expect (items .length ).toBe (10 );
@@ -185,12 +185,12 @@ describe('Testing react navigation', () => {
185185 < / NavigationContainer>
186186 );
187187
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' );
190190
191191 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' );
194194
195195 expect (newHeader).toBeTruthy ();
196196 expect (newBody).toBeTruthy ();
0 commit comments