Getbydisplayvalue React Testing Library <2025-2027>
test('select element by display value', () => render(<RoleSelect defaultValue="Admin" />);
// Edit the value await userEvent.clear(nameInput); await userEvent.type(nameInput, 'Bob'); getbydisplayvalue react testing library
// Assert updated display value expect(screen.getByDisplayValue('Bob')).toBeInTheDocument(); ); test('select element by display value'
// Assert initial display value expect(screen.getByDisplayValue('Alice')).toBeInTheDocument(); RoleSelect defaultValue="Admin" />
const nameInput = screen.getByLabelText(/name/i);