-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
For eg .
const buttonInsideContainer = screen.getByTestId('container').getByRole('button', { name : 'Test Button'})
This strategy helps avoid a lot of errors due to the selector resulting in multiple elements. I found this strategy being used in playwright. It pretty easy to uniquely select a specific element.
Lets take an example -
suppose we have a button deep inside a container. currently we have to first get the container like -
const container = screen.getByTestId('container');
and then use this container to uniquely select the button.
getByRole(container, 'button', {name : 'Test Button'});
Imagine how simple it will to be if we have chaining.
tw-anoopjadhav, shirakaba and ozyx
Metadata
Metadata
Assignees
Labels
No labels