Jest+React Native Testing Library: How to test an image src?
If you’re using @testing-library/react rather than @testing-library/react-native, and you have an alt attribute on your image, you can avoid using getByDataTestId and instead use getByAltText. it(‘uses correct src’, async () => { const { getByAltText } = await render(<MyComponent />); const image = getByAltText(‘the_alt_text’); expect(image.src).toContain(‘the_url’); // or expect(image).toHaveAttribute(‘src’, ‘the_url’) }); Documentation. Unfortunately, it appears that … Read more