Created
October 19, 2026 19:39
-
-
Save wilyJ80/def03ec2005c06cde4568dcb65d46fc7 to your computer and use it in GitHub Desktop.
rn integration test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { render, fireEvent, waitFor, act } from '@testing-library/react-native'; | |
| import HomeScreen from '@/app/index'; | |
| it('fetches the API and displays its response in a modal', async () => { | |
| const { getByTestId, queryByTestId } = await render(<HomeScreen />); | |
| expect(queryByTestId('api-response')).toBeNull(); | |
| await act(async () => { | |
| fireEvent.press(getByTestId('strawberry-button')); | |
| }) | |
| const response = await waitFor(() => { | |
| const element = getByTestId('api-response'); | |
| expect(element.props.children).toBe('{"status":"ok"}'); | |
| return element; | |
| }); | |
| expect(response).toBeTruthy(); | |
| await act(async () => { | |
| fireEvent.press(getByTestId('close-modal-button')); | |
| }) | |
| await waitFor(() => { | |
| expect(queryByTestId('api-response')).toBeNull(); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment