The main difference between the three (i.e. findBy*, getBy* and queryBy*) is that their return values differ:
#findBy* Methods
- When Match Is Found: Returns a resolved
Promise. - When Match Is Not Found: Returns a rejected
Promise.
#getBy* Methods
- When Match Is Found: Returns the node that matches the query.
- When Match Is Not Found: Throws an error.
#queryBy* Methods
- When Match Is Found: Returns the node that matches the query.
- When Match Is Not Found: Returns
null.
queryBy* methods can be useful for asserting an element that is not present (for example, expect(screen.queryByText('foo')).not.toBeInTheDocument()).