Skip to content

Instantly share code, notes, and snippets.

@wilyJ80
Created October 19, 2026 19:39
Show Gist options
  • Select an option

  • Save wilyJ80/def03ec2005c06cde4568dcb65d46fc7 to your computer and use it in GitHub Desktop.

Select an option

Save wilyJ80/def03ec2005c06cde4568dcb65d46fc7 to your computer and use it in GitHub Desktop.
rn integration test
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