getbydisplayvalue react testing library

const nameInput = screen.getByLabelText(/name/i);

test('select element by display value', () => render(<RoleSelect defaultValue="Admin" />);

// Edit the value await userEvent.clear(nameInput); await userEvent.type(nameInput, 'Bob');

// Assert updated display value expect(screen.getByDisplayValue('Bob')).toBeInTheDocument(); );

Getbydisplayvalue React Testing Library 〈Tested · 2026〉

const nameInput = screen.getByLabelText(/name/i);

test('select element by display value', () => render(<RoleSelect defaultValue="Admin" />);

// Edit the value await userEvent.clear(nameInput); await userEvent.type(nameInput, 'Bob');

// Assert updated display value expect(screen.getByDisplayValue('Bob')).toBeInTheDocument(); );