Created
April 15, 2024 13:34
-
-
Save maurer2/04ce44d16fcce9b93009d1e7a77b2e1b to your computer and use it in GitHub Desktop.
More readable "within" query in RTL
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
const parent = within(screen.getByRole('list', { name: 'test' })); | |
expect(parent.getByRole('list')).toBeVisible(); | |
expect(parent.getAllByRole('listitem')).toHaveLength(10); | |
or | |
const { getByRole, getAllByRole } = within(screen.getByRole('list', { name: 'test' })); | |
expect(getByRole('list')).toBeVisible(); | |
expect(getAllByRole('listitem')).toHaveLength(10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment