Why would you ever need to use the toBeOnTheScreen
matcher from jest-native. https://github.com/testing-library/jest-native#tobeonthescreen My understanding is in the example within the docs the getByTestId
would simply error if the 'child' element wasn't present so then writing the expect seems unnecessary. I could understand if queryByTestId
was used as this wouldn't cause the error.
const child = screen.getByTestId('child');
expect(child).toBeOnTheScreen();
Is it just to check if the element hasn't been removed between the time when you captured it and another point in the test? if so, the docs example seems a little misleading. What am I missing.